Add files using upload-large-folder tool
Browse files- .DS_Store +0 -0
- OASIS-1/.DS_Store +0 -0
- OASIS-1/sub-OASIS10253/.DS_Store +0 -0
- OASIS-1/sub-OASIS10253/ses-M000/.DS_Store +0 -0
- OASIS-1/sub-OASIS10280/.DS_Store +0 -0
- OASIS-1/sub-OASIS10280/ses-M000/.DS_Store +0 -0
- brain-structure.py +47 -44
.DS_Store
ADDED
Binary file (12.3 kB). View file
|
|
OASIS-1/.DS_Store
CHANGED
Binary files a/OASIS-1/.DS_Store and b/OASIS-1/.DS_Store differ
|
|
OASIS-1/sub-OASIS10253/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
OASIS-1/sub-OASIS10253/ses-M000/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
OASIS-1/sub-OASIS10280/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
OASIS-1/sub-OASIS10280/ses-M000/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
brain-structure.py
CHANGED
@@ -133,47 +133,50 @@ class BrainStructure(datasets.GeneratorBasedBuilder):
|
|
133 |
id_ = 0
|
134 |
for root, dirs, files in os.walk(data_dir):
|
135 |
for fname in files:
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
133 |
id_ = 0
|
134 |
for root, dirs, files in os.walk(data_dir):
|
135 |
for fname in files:
|
136 |
+
# Only consider sidecar files that start with "msub" and end with "_scandata.json"
|
137 |
+
if not (fname.startswith("msub") and fname.endswith("_scandata.json")):
|
138 |
+
continue
|
139 |
+
|
140 |
+
sidecar_path = os.path.join(root, fname)
|
141 |
+
with open(sidecar_path, "r") as f:
|
142 |
+
sidecar = json.load(f)
|
143 |
+
|
144 |
+
# if sidecar's "split" matches the desired_split...
|
145 |
+
if sidecar.get("split") == desired_split:
|
146 |
+
# attempt to find the .nii.gz with the same "msub" prefix
|
147 |
+
possible_nii_prefix = fname.replace("_scandata.json", "_T1w")
|
148 |
+
nii_filepath = None
|
149 |
+
for potential_file in files:
|
150 |
+
if (potential_file.startswith(possible_nii_prefix)
|
151 |
+
and potential_file.endswith(".nii.gz")):
|
152 |
+
nii_filepath = os.path.join(root, potential_file)
|
153 |
+
break
|
154 |
+
|
155 |
+
if not nii_filepath:
|
156 |
+
logger.warning(f"No corresponding .nii.gz file found for {sidecar_path}")
|
157 |
+
continue
|
158 |
+
|
159 |
+
yield id_, {
|
160 |
+
"id": str(id_),
|
161 |
+
"nii_filepath": nii_filepath,
|
162 |
+
"metadata": {
|
163 |
+
"split": sidecar.get("split", ""),
|
164 |
+
"participant_id": sidecar.get("participant_id", ""),
|
165 |
+
"session_id": sidecar.get("session_id", ""),
|
166 |
+
"study": sidecar.get("study", ""),
|
167 |
+
"age": sidecar.get("age", 0),
|
168 |
+
"sex": sidecar.get("sex", ""),
|
169 |
+
"clinical_diagnosis": sidecar.get("clinical_diagnosis", ""),
|
170 |
+
"scanner_manufacturer": sidecar.get("scanner_manufacturer", ""),
|
171 |
+
"scanner_model": sidecar.get("scanner_model", ""),
|
172 |
+
"field_strength": sidecar.get("field_strength", ""),
|
173 |
+
"image_quality_rating": float(sidecar.get("image_quality_rating", 0.0)),
|
174 |
+
"total_intracranial_volume": float(sidecar.get("total_intracranial_volume", 0.0)),
|
175 |
+
"license": sidecar.get("license", ""),
|
176 |
+
"website": sidecar.get("website", ""),
|
177 |
+
"citation": sidecar.get("citation", ""),
|
178 |
+
"t1_file_name": sidecar.get("t1_file_name", ""),
|
179 |
+
"radiata_id": sidecar.get("radiata_id", 0),
|
180 |
+
},
|
181 |
+
}
|
182 |
+
id_ += 1
|