質問編集履歴

3

追加

2021/09/30 23:44

投稿

Deep_passion
Deep_passion

スコア45

test CHANGED
File without changes
test CHANGED
File without changes

2

追加

2021/09/30 23:44

投稿

Deep_passion
Deep_passion

スコア45

test CHANGED
File without changes
test CHANGED
@@ -259,3 +259,13 @@
259
259
  Jupyter Lab version 1.1.4
260
260
 
261
261
  macbookpro 16
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+ でーたの追加
270
+
271
+ [こちらのtrainのなかにあります。](https://www.kaggle.com/c/rsna-miccai-brain-tumor-radiogenomic-classification/data)

1

文字追加

2021/09/30 23:43

投稿

Deep_passion
Deep_passion

スコア45

test CHANGED
File without changes
test CHANGED
@@ -60,6 +60,140 @@
60
60
 
61
61
 
62
62
 
63
+
64
+
65
+
66
+
67
+
68
+
69
+ コードはあまりみないのでなれないと思います。ですので、簡単にまとめます。
70
+
71
+ dicom形式のmri画像をflairモダリティをt1,t2から作成しています。
72
+
73
+ つまり、画像が3つ重なっていて、それをresampleしてるってことです。
74
+
75
+
76
+
77
+ shapeがあっていればいいのではないのですか?
78
+
79
+ よくわかりかねます。そのあたりが、グレイスケールに変更しているのにも関わらずです.
80
+
81
+
82
+
83
+
84
+
85
+ ```ここに言語を入力
86
+
87
+ reader = sitk.ImageSeriesReader()
88
+
89
+ reader.LoadPrivateTagsOn()
90
+
91
+ def resample(image, ref_image):
92
+
93
+
94
+
95
+ resampler = sitk.ResampleImageFilter()
96
+
97
+ resampler.SetReferenceImage(ref_image)
98
+
99
+ resampler.SetInterpolator(sitk.sitkLinear)
100
+
101
+
102
+
103
+ resampler.SetTransform(sitk.AffineTransform(image.GetDimension()))
104
+
105
+
106
+
107
+ resampler.SetOutputSpacing(ref_image.GetSpacing())
108
+
109
+
110
+
111
+ resampler.SetSize(ref_image.GetSize())
112
+
113
+
114
+
115
+ resampler.SetOutputDirection(ref_image.GetDirection())
116
+
117
+
118
+
119
+ resampler.SetOutputOrigin(ref_image.GetOrigin())
120
+
121
+
122
+
123
+ resampler.SetDefaultPixelValue(image.GetPixelIDValue())
124
+
125
+
126
+
127
+ resamped_image = resampler.Execute(image)
128
+
129
+
130
+
131
+ return resamped_image
132
+
133
+ %%time
134
+
135
+ # filenamesDICOM = reader.GetGDCMSeriesFileNames(f'{train_path}/{train_dirs[2]}/T1w')
136
+
137
+ filenamesDICOM = reader.GetGDCMSeriesFileNames(f'{train_path}/00524/T1w')
138
+
139
+
140
+
141
+ reader.SetFileNames(filenamesDICOM)
142
+
143
+ t1_sitk = reader.Execute()
144
+
145
+
146
+
147
+ filenamesDICOM = reader.GetGDCMSeriesFileNames(f'{train_path}/00524/FLAIR')
148
+
149
+ # filenamesDICOM = reader.GetGDCMSeriesFileNames(f'{train_path}/{train_dirs[2]}/FLAIR')
150
+
151
+ reader.SetFileNames(filenamesDICOM)
152
+
153
+ flair_sitk = reader.Execute()
154
+
155
+
156
+
157
+ # filenamesDICOM = reader.GetGDCMSeriesFileNames(f'{train_path}/{train_dirs[2]}/T2w')
158
+
159
+ filenamesDICOM = reader.GetGDCMSeriesFileNames(f'{train_path}/00524/T2w')
160
+
161
+
162
+
163
+ reader.SetFileNames(filenamesDICOM)
164
+
165
+ t2_sitk = reader.Execute()
166
+
167
+
168
+
169
+ flair_resampled = resample(flair_sitk, t1_sitk)
170
+
171
+ t2_resampled = resample(t2_sitk, t1_sitk)
172
+
173
+
174
+
175
+ t1_sitk_array = normalize(sitk.GetArrayFromImage(t1_sitk))
176
+
177
+ flair_resampled_array = normalize(sitk.GetArrayFromImage(flair_resampled))
178
+
179
+ t2_resampled_array = normalize(sitk.GetArrayFromImage(t2_resampled))
180
+
181
+
182
+
183
+ stacked = np.stack([t1_sitk_array, t2_resampled_array, flair_resampled_array,])
184
+
185
+
186
+
187
+ to_rgb = stacked[:,t1_sitk_array.shape[0]//2,:,:].transpose(1,2,0)
188
+
189
+ im = Image.fromarray((to_rgb * 255).astype(np.uint8))
190
+
191
+ ```
192
+
193
+
194
+
195
+
196
+
63
197
  ### 該当のソースコード
64
198
 
65
199