回答編集履歴
2
追記
answer
CHANGED
@@ -23,4 +23,15 @@
|
|
23
23
|
print(file_dic[k])
|
24
24
|
```
|
25
25
|
|
26
|
-
※上記は一例です。他にも様々な関数などもあります。
|
26
|
+
※上記は一例です。他にも様々な関数などもあります。
|
27
|
+
|
28
|
+
【追記】
|
29
|
+
```Python
|
30
|
+
for k in file_dic:
|
31
|
+
refds = pydicom.dcmread(file_dic[k][0])
|
32
|
+
constpixeldims = (int(refds.Rows), int(refds.Columns), len(file_dic[k]))
|
33
|
+
arraydicom = numpy.zeros(constpixeldims,dtype=refds.pixel_array.dtype)
|
34
|
+
for namedcm in file_dict[k]:
|
35
|
+
ds = pydicom.dcmread(namedcm)
|
36
|
+
arraydicom[:,:,list.index(namedcm)] = ds.pixel_array
|
37
|
+
```
|
1
コード例を追加
answer
CHANGED
@@ -5,4 +5,22 @@
|
|
5
5
|
list.append(os.path.join(root, name))
|
6
6
|
```
|
7
7
|
|
8
|
-
root毎に今の画像処理を行うのはどうでしょうか?(os.path.join(root, name)はそこで行う)
|
8
|
+
root毎に今の画像処理を行うのはどうでしょうか?(os.path.join(root, name)はそこで行う)
|
9
|
+
|
10
|
+
【追記】
|
11
|
+
```python
|
12
|
+
file_dic = {} #ファイルリストの辞書
|
13
|
+
for root, dirs, files in os.walk(path):
|
14
|
+
for name in files:
|
15
|
+
if root in file_dic: #既にあるディレクトリにファイル名を追加
|
16
|
+
dic[root].append(name)
|
17
|
+
else: #初めてのディレクトリの場合(複数枚に対応するためリストにする)
|
18
|
+
dic[root] = [name]
|
19
|
+
|
20
|
+
|
21
|
+
#取り出すとき
|
22
|
+
for k in file_dic: #k:ディレクトリ file_dic[k]:ファイル
|
23
|
+
print(file_dic[k])
|
24
|
+
```
|
25
|
+
|
26
|
+
※上記は一例です。他にも様々な関数などもあります。
|