# -*- coding: utf-8 -*-\n\nimport pydicom\nfrom matplotlib import pyplot as plt\nfrom matplotlib.widgets import Slider\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000#matplotlib\u306eSlider\u3068\u3044\u3046\u30a6\u30a4\u30b8\u30c3\u30c8\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\n\n\n#############\u4eca\u56de\u306e\u30b3\u30fc\u30c9\u3092\u30da\u30fc\u30b9\u30c8#########################\n\nimport tkinter \u3000\u3000\u3000\u3000\u3000\u3000#tkinter\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\nfrom tkinter import filedialog as tkFileDialog\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000 #tkinter\u306efiledialog\u3092\u30a4\u30f3\u30dd\u30fc\u30c8 \n\ndef fileselect():\n root=tkinter.Tk() \u3000\u3000 #tkinter\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\n root.withdraw() #\u3053\u306e\u4e00\u6587\u304c\u7121\u3044\u3068\u8b0e\u306e\u9ed2\u3044\u30a6\u30a4\u30f3\u30c9\u30a6\u304c\u51fa\u3066\u304f\u308b\u3089\u3057\u3044\n\n fTyp=[('','*')]\u3000\u3000\u3000 #\u30c0\u30a4\u30a2\u30ed\u30b0\u306b\u8868\u793a\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u7a2e\u985e\u3092\u6307\u5b9a\u3002\n #\u4eca\u56de\u306f\u6307\u5b9a\u306a\u3057\n #fTyp=[('\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb','*.txt')] \n #\u4e0a\u8a18\u306e\u69d8\u306b\u3059\u308c\u3070\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u307f\u306b\u7d5e\u308c\u308b\u3002\n #()\u3092\u8db3\u3057\u3066\u3044\u304f\u3053\u3068\u3067\u8907\u6570\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3002\n\n iDir='C:\/Desktop' \u3000\u3000#\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u958b\u304f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u6307\u5b9a\n #\u4eca\u56de\u306f\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\n\n \n filename = tkFileDialog.askopenfilename(filetypes=fTyp, initialdir=iDir)\n return filename\u3000\u3000\u3000\u3000#\u9078\u629e\u30d5\u30a1\u30a4\u30eb\u306e\u7d76\u5bfe\u30d1\u30b9\u3092\u8fd4\u3057\u307e\u3059\u3002\n\n<\/code><\/pre>\n\n\n\n\u7d9a\u3044\u3066\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u958b\u3044\u3066\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a\u3059\u308b\u90e8\u5206\u3092\u95a2\u6570\u3068\u3057\u3066\u8a18\u8f09\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n
\u524d\u56de\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f<\/p>\n\n\n\n
ds = pydicom.dcmread(‘CT000060’)<\/p>\n\n\n\n
\u306e\u90e8\u5206\u3067\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u306e\u524d\u306b\u5909\u6570(fname)\u3068\u3057\u3066\u30d5\u30a1\u30a4\u30eb\u306e\u7d76\u5bfe\u30d1\u30b9\u3092\u53d7\u3051\u53d6\u308a\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n
fname = fileselect ()<\/p>\n\n\n\n
\u3068\u3059\u308b\u3053\u3068\u3067fname\u3068\u3044\u3046\u95a2\u6570\u306bfileselect\u95a2\u6570\u3067\u53d6\u5f97\u3057\u305f\u7d76\u5bfe\u30d1\u30b9\u3092\u683c\u7d0d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n
\u305d\u3057\u3066\u3001\u76f4\u63a5\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u6307\u5b9a\u3057\u3066\u3044\u305f\u90e8\u5206\u3092\u5909\u6570fname\u3068\u3059\u308b\u3053\u3068\u3067\u30c0\u30a4\u30a2\u30ed\u30b0\u3067\u9078\u629e\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n
fname = fileselect()\u3000\u3000 #fileselect\u306e\u6700\u5f8creturn\u3067\u8fd4\u3055\u308c\u305f\u3082\u306e\u3092fname\u306b\u683c\u7d0d\n\nds = pydicom.dcmread(fname)\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000 #'CT000060'\u3068\u6307\u5b9a\u3057\u3066\u305f\u30d5\u30a1\u30a4\u30eb\u3092fname\u3068\u66f8\u304d\u63db\u3048\u308b\n\n<\/code><\/pre>\n\n\n\n\u305d\u308c\u3067\u306f\u3001\u4fee\u6b63\u3057\u305f\u30b3\u30fc\u30c9\u5168\u4f53\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n
<\/p>\n\n\n\n
\u5b8c\u6210\u30b3\u30fc\u30c9<\/h3>\n\n\n\n# -*- coding: utf-8 -*-\n\nimport pydicom\nfrom matplotlib import pyplot as plt\nfrom matplotlib.widgets import Slider\n #matplotlib\u306eSlider\u3068\u3044\u3046\u30a6\u30a4\u30b8\u30c3\u30c8\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\n\n\n#############\u3053\u3053\u304b\u3089\u4eca\u56de\u306e\u30b3\u30fc\u30c9#################\n\nimport tkinter #tkinter\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\nfrom tkinter import filedialog as tkFileDialog\n #tkinter\u306efiledialog\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\n\ndef fileselect():\n root=tkinter.Tk() #tkinter\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\n root.withdraw() #\u3053\u306e\u4e00\u6587\u304c\u7121\u3044\u3068\u8b0e\u306e\u9ed2\u3044\u30a6\u30a4\u30f3\u30c9\u30a6\u304c\u51fa\u3066\u304f\u308b\u3089\u3057\u3044\n\n fTyp=[('','*')] #\u30c0\u30a4\u30a2\u30ed\u30b0\u306b\u8868\u793a\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u7a2e\u985e\u3092\u6307\u5b9a\u3002\n #\u4eca\u56de\u306f\u6307\u5b9a\u306a\u3057\n #fTyp=[('\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb','*.txt')]\n #\u4e0a\u8a18\u306e\u69d8\u306b\u3059\u308c\u3070\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u307f\u306b\u7d5e\u308c\u308b\u3002\n #()\u3092\u8db3\u3057\u3066\u3044\u304f\u3053\u3068\u3067\u8907\u6570\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3002\n\n iDir='C:\/Desktop' #\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u958b\u304f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u6307\u5b9a\n #\u4eca\u56de\u306f\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\n\n \n filename = tkFileDialog.askopenfilename(filetypes=fTyp, initialdir=iDir)\n return filename #\u9078\u629e\u30d5\u30a1\u30a4\u30eb\u306e\u7d76\u5bfe\u30d1\u30b9\u3092\u8fd4\u3057\u307e\u3059\u3002\n\n#############\u3053\u3053\u307e\u3067\u304c\u4eca\u56de\u306e\u30b3\u30fc\u30c9###############\n\n#############\u4ee5\u4e0b\u4fee\u6b63\u3057\u305f\u90e8\u5206#####################\n\nfname = fileselect() #fileselect\u306e\u6700\u5f8creturn\u3067\u8fd4\u3055\u308c\u305f\u3082\u306e\u3092fname\u306b\u683c\u7d0d\n\nds = pydicom.dcmread(fname)\n #'CT000060'\u3068\u6307\u5b9a\u3057\u3066\u305f\u30d5\u30a1\u30a4\u30eb\u3092fname\u3068\u66f8\u304d\u63db\u3048\u308b\n\n#############\u3053\u3053\u307e\u3067\u304c\u4fee\u6b63\u3057\u305f\u90e8\u5206################\n\n\nlow = -140 #WW\u3092-140\uff5e260\u306e\u7bc4\u56f2\u3067\u8868\u793a\u3057\u305f\u3044\u305f\u3081\nhigh = 260 #WL\u306f-140\uff5e260\u306e\u4e2d\u592e\u5024\u3067\u3042\u308b60\u306b\u306a\u308a\u307e\u3059\u3002\n\nfig = plt.figure(figsize=(5, 6)) #\u753b\u50cf\u3001\u30b9\u30e9\u30a4\u30c0\u3092\u8868\u793a\u3059\u308b\u9818\u57df\u306e\u8a2d\u5b9a\n\nimg = plt.imshow(ds.pixel_array, cmap=plt.cm.bone, vmin=low, vmax=high)\n #img\u3068\u3044\u3046\u5909\u6570\u306b\u753b\u50cf\u8868\u793a\u8a2d\u5b9a\u3092\u5165\u308c\u308b\u3002\n\nwl_slider_pos = plt.axes([0.1, 0.08, 0.8, 0.03])\nww_slider_pos = plt.axes([0.1, 0.01, 0.8, 0.03])\n #ww\u3001wl\u306e\u30b9\u30e9\u30a4\u30c0\u3092\u8868\u793a\u3059\u308b\u4f4d\u7f6e\u306e\u8a2d\u5b9a\n\nwl_slider = Slider(wl_slider_pos, 'wl', 0, 500, valinit=175)\nww_slider = Slider(ww_slider_pos, 'ww', 0, 2000, valinit=350)\n #ww\u3001wl\u306e\u30b9\u30e9\u30a4\u30c0\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\n\ndef update(slider_val): #\u30b9\u30e9\u30a4\u30c0\u3092\u52d5\u304b\u3057\u305f\u3068\u304d\u306e\u51e6\u7406\n ww = ww_slider.val\n wl = wl_slider.val\n #ww\u3001wl\u306e\u30b9\u30e9\u30a4\u30c0\u306e\u5024\u3092\u53d6\u5f97\n\n low = int(wl - ww\/2)\n high = int(wl + ww\/2)\n #ww\u306e\u4e0a\u9650\u5024\u3068\u4e0b\u9650\u5024\u3092\u8a08\u7b97\n\n img.set_clim([low, high])\n #\u753b\u50cf\u8868\u793a\u306e\u8a2d\u5b9aimg\u306elow,high\u306e\u5024\u3092\u66f4\u65b0\n\n fig.canvas.update()\n #\u8868\u793a\u3057\u3066\u3044\u308b\u753b\u50cf\u3092\u66f4\u65b0\n\nwl_slider.on_changed(update)\nww_slider.on_changed(update)\n #\u30b9\u30e9\u30a4\u30c0\u30fc\u3092\u52d5\u304b\u3057\u305f\u3068\u304d\u306e\u51e6\u7406\u3092\u6307\u5b9a(25\u884c\u76ee\u306b)\n\nplt.show()\n #\u753b\u50cf\u3092\u8868\u793a\n\n<\/code><\/pre>\n\n\n\n\u3044\u304b\u304c\u3067\u3057\u305f\u304b\uff1f<\/p>\n\n\n\n
\u6b21\u56de\u306f\u3001\u30c0\u30a4\u30a2\u30ed\u30b0\u3067\u8907\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3059\u308b\u65b9\u6cd5\u3092\u3084\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n
<\/p>\n\n\n\n
\u74b0\u5883<\/h2>\n\n\n\n- windows10<\/li>
- python3.6.1 <\/li>
- Anaconda custom(64-bit)<\/li>
- PyCharm2020.2(Communication Edition)<\/li><\/ul>\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n\n\n\n
<\/p>\n","protected":false},"excerpt":{"rendered":"
\u30c0\u30a4\u30a2\u30ed\u30b0\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3059\u308b\u3002 \u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3053\u3046 […]<\/p>\n","protected":false},"author":1,"featured_media":363,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4,23],"tags":[7],"class_list":["post-233","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-23","tag-python"],"aioseo_notices":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/radiology-technologist.info\/wp-content\/uploads\/2019\/11\/python_logo.png?fit=614%2C612","_links":{"self":[{"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/posts\/233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/comments?post=233"}],"version-history":[{"count":10,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/posts\/233\/revisions"}],"predecessor-version":[{"id":1478,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/posts\/233\/revisions\/1478"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/media\/363"}],"wp:attachment":[{"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/media?parent=233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/categories?post=233"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/tags?post=233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}