{"id":136,"date":"2023-05-28T15:50:47","date_gmt":"2023-05-28T15:50:47","guid":{"rendered":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/?p=136"},"modified":"2023-05-28T16:10:40","modified_gmt":"2023-05-28T16:10:40","slug":"xdsviewer","status":"publish","type":"post","link":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/2023\/05\/28\/xdsviewer\/","title":{"rendered":"XDS\u306e\u56de\u6298\u70b9viewer"},"content":{"rendered":"\n<p>\u653e\u5c04\u5149X\u7dda\u56de\u6298\u306b\u304a\u3051\u308b2\u6b21\u5143\u691c\u51fa\u5668\u4e0a\u306e\u753b\u50cf\u89e3\u6790\u306b\u7528\u3044\u308b<a href=\"https:\/\/wiki.uni-konstanz.de\/xds\/index.php\/Xds\">XDS<\/a>\u306flinux\u4e0a\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u5b9f\u884c\u3059\u308b\u305f\u3081\u4e07\u4eba\u5411\u304d\u3067\u306f\u306a\u3044\u3067\u3059\u304c\u5f37\u529b\u306a\u5438\u53ce\u88dc\u6b63\u6a5f\u80fd\u304c\u9b45\u529b\u3067\u3059\u3002\u305d\u306e\u4e00\u65b9\u3067\u3001\u53cd\u5c04\u306eprediction\u78ba\u8a8d\u306b\u96e3\u304c\u3042\u308b\u305f\u3081\u56de\u6298\u70b9viewer\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002ADXV\u3092\u5916\u90e8\u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u3057\u3066cbf\u304b\u3089jpeg\u306b\u5909\u63db\u3057\u3001XDS_ASCII.HKL\u306b\u3042\u308bprediction\u3092\u89b3\u6e2c\u3057\u305f\u50cf\u306b\u91cd\u306d\u5408\u308f\u305b\u308bpython\u30b3\u30fc\u30c9\u304c\u4ee5\u4e0b\u3067\u3059\u3002\u3042\u304f\u307e\u3067\u7c21\u6613\u7684\u306a\u3082\u306e\u306a\u306e\u3067\u305d\u306e\u70b9\u8003\u616e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code># -*- coding: utf-8 -*-\n# \u30d4\u30e9\u30bf\u30b9\u306a\u3069\u306e2\u6b21\u5143\u691c\u51fa\u5668\u3067\u64ae\u5f71\u3057XDS\u3067\u89e3\u6790\u3057\u305f\u3068\u304d\u306b\u53cd\u5c04\u306eprediction\u3092\u9023\u7d9a\u7684\u306b\u898b\u305f\u3044\u6642\u304c\u3042\u308a\u307e\u3059\n# ADXV\u3092\u5916\u90e8\u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u3057\u3066cbf\u304b\u3089jpeg\u306b\u5909\u63db\u3057\u3001XDS_ASCII.HKL\u306b\u3042\u308b\u53cd\u5c04prediction\u3092\u91cd\u306d\u5408\u308f\u305b\u308b\u30b3\u30fc\u30c9\u3067\u3059\u3001SPOT.XDS\u306b\u5909\u66f4\u3057\u3066\u3082\u3088\u3044\u3067\u3059\n# 0\u304b\u3089frame_num\u307e\u3067\u3092step_num\u3067\u98db\u3070\u3057\u3066frame_num\/step_num\u679a\u306ejpeg\u3092\u4f5c\u6210\u3057\u307e\u3059\n# \u66f8\u304d\u51fa\u3057\u5c02\u7528dir\u3092\u4f5c\u308a\u3001\u305d\u3053\u3067ImageJ\u306estacking\u6a5f\u80fd\u3092\u5229\u7528\u3057\u3066\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\n# \u306a\u306e\u3067PATH\u304c\u8a2d\u5b9a\u6e08\u307f\u306eADXV\u304c\u5fc5\u8981\u3067\u3059\u3001\u9069\u5b9cdir\u3001file\u540d\u3092\u66f8\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\n# \u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3066\u307e\u3059\u304c\u3001cv2\u3092\u4f7f\u3063\u305frainbow\u7591\u4f3c\u30ab\u30e9\u30fc\u306e\u30bb\u30c3\u30c8\u3082\u4f5c\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u307e\u3059\n# Linux terminal\u4e0a\u3067&gt;&gt;python3 xds-spotview.py \u4ed6\u304a\u597d\u307f\u306e\u65b9\u6cd5\u3067\u52d5\u304b\u3057\u3066\u304f\u3060\u3055\u3044\n#\u5171\u540c\u5229\u7528\u8005\u4ee5\u5916\u3078\u306e\u5229\u7528\u8cac\u4efb\u306f\u306a\u304f\u8cea\u554f\u53d7\u4ed8\u306f\u3057\u307e\u305b\u3093\u3002D2MatE\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u652f\u63f4\u3092\u53d7\u3051\u3066\u884c\u308f\u308c\u3066\u3044\u307e\u3059\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom PIL import Image\nimport subprocess\n#import cv2\n\n# setting parameter\ndelta_omega = 0.1 # delta omega value\nmosaicity = 0.5 # draw the frame in Evald_frame+-mosaicity\/delta_omega\ndelta_frame = mosaicity\/delta_omega\nstart_frame = 100 # start frame of cbf-to-jpeg\nend_frame = 1800\nstep_num = 50 # prediction steps: frame_num\/step_num frames will be converted\ncbf_file = &#39;.\/image-tth30\/220213_cytidine_m90-90_2_&#39; # cbf file without numbering and extension\njpg_file = &#39;cytidine-tth30HS_&#39; # jpg file without numbering and extension\njpgsp_file = &#39;.\/imagestack\/cytidine-tth30HS_sp_&#39; # jpg file with SPOT without numbering and extension\nXDS_FullSPOT = &#39;XDS_ASCII.HKL&#39; # XDS SPOT list\n# jpg_col_file = &#39;test_col_&#39; # jpg file without numbering and extension\n\n# SPOT data reading to pandas DataFrame\ndf1 = pd.read_csv(XDS_FullSPOT, delim_whitespace=True, comment=&quot;!&quot;, header=None, usecols=[0,1,2], names=[&#39;h&#39;,&#39;k&#39;,&#39;l&#39;], dtype=&#39;int&#39;)\ndf2 = pd.read_csv(XDS_FullSPOT, delim_whitespace=True, comment=&quot;!&quot;, header=None, usecols=[5,6,7], names=[&#39;dfx&#39;,&#39;dfy&#39;,&#39;dfz&#39;], dtype=&#39;float&#39;)\ndf_s = pd.concat([df1, df2], axis=1).sort_values(&#39;dfz&#39;)  # conbine df1 (=dfx,dfy,dfz) and df2 (flag,h,k,l)\n\n# main routine of SPOT selection, SPOT draw, convert cbf-to-jpg, jpg draw with SPOT\nfor Ewald_frame in range(start_frame, end_frame, step_num):\n\n    # selection the SPOT data near the Bragg condiction\n    bfEw_frame = int(Ewald_frame - delta_frame)\n    afEw_frame = int(Ewald_frame + delta_frame)\n    df_bfEw = df_s[(bfEw_frame &lt; df_s[&#39;dfz&#39;]) & (df_s[&#39;dfz&#39;] &lt; Ewald_frame)]\n    df_onEw = df_s[df_s[&#39;dfz&#39;].astype(int) == Ewald_frame ]\n    df_afEw = df_s[(Ewald_frame &lt; df_s[&#39;dfz&#39;]) & (df_s[&#39;dfz&#39;] &lt; afEw_frame)]\n    print(Ewald_frame)\n    print(df_bfEw)\n    print(df_onEw)\n    print(df_afEw)\n\n    # plot scatter figure of SPOT data\n    fig, ax = plt.subplots(figsize=(10,10))\n    plt.xlim(1, 981)\n    plt.ylim(1034, 1)\n    plt.rcParams[&quot;font.size&quot;] = 18\n    plt.xlabel(&#39;pixcel x&#39;)\n    plt.ylabel(&#39;pixcel y&#39;)\n    plt.scatter(df_bfEw[&#39;dfx&#39;], df_bfEw[&#39;dfy&#39;], marker=&quot;D&quot;, s=100, facecolor=&#39;None&#39;, edgecolors=&#39;blue&#39;)\n    plt.scatter(df_onEw[&#39;dfx&#39;], df_onEw[&#39;dfy&#39;], marker=&quot;o&quot;, s=100, facecolor=&#39;None&#39;, edgecolors=&#39;blue&#39;)\n    plt.scatter(df_afEw[&#39;dfx&#39;], df_afEw[&#39;dfy&#39;], marker=&quot;s&quot;, s=100, facecolor=&#39;None&#39;, edgecolors=&#39;blue&#39;)\n\n    # convert cbf-to-jpg file on ADXV\n    fnamecbf = cbf_file + f&#39;{Ewald_frame:05d}&#39; + &#39;.cbf&#39;\n    fnamejpg = jpg_file + f&#39;{Ewald_frame:05d}&#39; + &#39;.jpeg&#39;\n    #fnamejpg_col = jpg_col_file + f&#39;{Ewald_frame:05d}&#39; + &#39;.jpeg&#39;\n    # change the {0:05d} part depending on the file number of digits\n    cmd = &#39;adxv -sa -jpeg_scale 0.9 &#39;+ fnamecbf + &#39; &#39; +fnamejpg\n    print(cmd)\n    subprocess.run(cmd, shell=True)\n\n    # plot jpg data with the SPOT\n    fnamejpgsp = jpgsp_file + f&#39;{Ewald_frame:05d}&#39; + &#39;.jpeg&#39;\n    im = Image.open(fnamejpg)\n    xlim_size = ax.get_xlim()\n    ylim_size = ax.get_ylim()\n    plt.imshow(im, extent=[*xlim_size, *ylim_size], aspect=&#39;auto&#39;, alpha=1)\n    plt.savefig(fnamejpgsp)\n    #pic=cv2.imread(fnamejpg)\n    #rb_color = cv2.applyColorMap(pic, cv2.COLORMAP_RAINBOW)\n    #cv2.imwrite(fnamejpg_col, np.array(rb_color))\n\n<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u653e\u5c04\u5149X\u7dda\u56de\u6298\u306b\u304a\u3051\u308b2\u6b21\u5143\u691c\u51fa\u5668\u4e0a\u306e\u753b\u50cf\u89e3\u6790\u306b\u7528\u3044\u308bXDS\u306flinux\u4e0a\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u5b9f\u884c\u3059\u308b\u305f\u3081\u4e07\u4eba\u5411\u304d\u3067\u306f\u306a\u3044\u3067\u3059\u304c\u5f37\u529b\u306a\u5438\u53ce\u88dc\u6b63\u6a5f\u80fd\u304c\u9b45\u529b\u3067\u3059\u3002\u305d\u306e\u4e00\u65b9\u3067\u3001\u53cd\u5c04\u306eprediction\u78ba\u8a8d\u306b\u96e3\u304c\u3042\u308b\u305f\u3081\u56de\u6298\u70b9viewer\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002ADXV\u3092\u5916\u90e8\u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u3057\u3066cbf\u304b\u3089jpeg\u306b\u5909\u63db\u3057\u3001XDS_ASCII.HKL\u306b\u3042\u308bprediction\u3092\u89b3\u6e2c\u3057\u305f\u50cf\u306b\u91cd\u306d\u5408\u308f\u305b\u308bpython\u30b3\u30fc\u30c9\u304c\u4ee5\u4e0b\u3067\u3059\u3002\u3042\u304f\u307e\u3067\u7c21\u6613\u7684\u306a\u3082\u306e\u306a\u306e\u3067\u305d\u306e\u70b9\u8003\u616e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,7,3],"tags":[],"class_list":["post-136","post","type-post","status-publish","format-standard","hentry","category-d2mate","category-synchrotron","category-research"],"_links":{"self":[{"href":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/wp-json\/wp\/v2\/posts\/136"}],"collection":[{"href":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/wp-json\/wp\/v2\/comments?post=136"}],"version-history":[{"count":7,"href":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/wp-json\/wp\/v2\/posts\/136\/revisions"}],"predecessor-version":[{"id":148,"href":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/wp-json\/wp\/v2\/posts\/136\/revisions\/148"}],"wp:attachment":[{"href":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/wp-json\/wp\/v2\/media?parent=136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/wp-json\/wp\/v2\/categories?post=136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yamaura-group.issp.u-tokyo.ac.jp\/index.php\/wp-json\/wp\/v2\/tags?post=136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}