@@ -275,46 +275,49 @@ def create(
275275 patient_path = patient_dataset .patient_path
276276
277277 if shallow_hierarchy is True :
278- patient_group = file
278+ patient_group = file
279279 else :
280- patient_group = file .create_group (name = patient_id )
280+ patient_group = file .create_group (name = patient_id )
281281
282282 for image_idx , patient_image_data in enumerate (patient_dataset .data ):
283283
284284 if shallow_hierarchy is True :
285- series_group = patient_group
286- image_name = os .path .basename (os .path .normpath (patient_path ))
285+ series_group = patient_group
286+ image_name = os .path .basename (os .path .normpath (patient_path ))
287287 else :
288- series_group = patient_group .create_group (name = str (image_idx ))
289- image_name = self .IMAGE
288+ series_group = patient_group .create_group (name = str (image_idx ))
289+ image_name = self .IMAGE
290290
291- self ._add_dicom_attributes_to_hdf5_group (
292- patient_image_data , series_group , tags_to_use_as_attributes
293- )
291+ self ._add_dicom_attributes_to_hdf5_group (
292+ patient_image_data , series_group , tags_to_use_as_attributes
293+ )
294294
295- if add_sitk_image_metadata_as_attributes :
296- self ._add_sitk_image_attributes_to_hdf5_group (patient_image_data , series_group )
295+ if add_sitk_image_metadata_as_attributes :
296+ self ._add_sitk_image_attributes_to_hdf5_group (patient_image_data , series_group )
297297
298- series_group .create_dataset (
299- name = self .DICOM_HEADER ,
300- data = json .dumps (patient_image_data .image .dicom_header .to_json_dict ())
301- )
298+ series_group .create_dataset (
299+ name = self .DICOM_HEADER ,
300+ data = json .dumps (patient_image_data .image .dicom_header .to_json_dict ())
301+ )
302302
303303 if transpose is True :
304- image_array = self ._transpose (sitk .GetArrayFromImage (patient_image_data .image .simple_itk_image ))
304+ image_array = self ._transpose (sitk .GetArrayFromImage (patient_image_data .image .simple_itk_image ))
305305 else :
306- image_array = sitk .GetArrayFromImage (patient_image_data .image .simple_itk_image )
306+ image_array = sitk .GetArrayFromImage (patient_image_data .image .simple_itk_image )
307307
308308 data_set = series_group .create_dataset (
309309 name = image_name ,
310310 data = self ._transpose (image_array )
311+ )
311312
312313 if shallow_hierarchy is True :
313- self ._add_dicom_attributes_to_hdf5_group (
314- patient_image_data , data_set , tags_to_use_as_attributes
315- )
316- if add_sitk_image_metadata_as_attributes :
317- self ._add_sitk_image_attributes_to_hdf5_group (patient_image_data , data_set )
314+ self ._add_dicom_attributes_to_hdf5_group (
315+ patient_image_data ,
316+ data_set ,
317+ tags_to_use_as_attributes
318+ )
319+ if add_sitk_image_metadata_as_attributes :
320+ self ._add_sitk_image_attributes_to_hdf5_group (patient_image_data , data_set )
318321
319322 if patient_image_data .segmentations :
320323 for segmentation_idx , segmentation in enumerate (patient_image_data .segmentations ):
@@ -323,7 +326,9 @@ def create(
323326
324327 for organ , simple_itk_label_map in segmentation .simple_itk_label_maps .items ():
325328 if transpose is True :
326- numpy_array_label_map = self ._transpose (sitk .GetArrayFromImage (simple_itk_label_map ))
329+ numpy_array_label_map = self ._transpose (
330+ sitk .GetArrayFromImage (simple_itk_label_map )
331+ )
327332 else :
328333 numpy_array_label_map = sitk .GetArrayFromImage (simple_itk_label_map )
329334
@@ -336,21 +341,21 @@ def create(
336341
337342 for idx , transform in enumerate (patient_dataset .transforms_history .history ):
338343 if shallow_hierarchy is True :
339- data_set .attrs .create (
340- name = f"{ self .TRANSFORMS } _{ idx } " ,
341- data = json .dumps (
342- obj = transform ,
343- default = patient_dataset .transforms_history .serialize
344- )
345- )
344+ data_set .attrs .create (
345+ name = f"{ self .TRANSFORMS } _{ idx } " ,
346+ data = json .dumps (
347+ obj = transform ,
348+ default = patient_dataset .transforms_history .serialize
349+ )
350+ )
346351 else :
347- patient_group .attrs .create (
348- name = f"{ self .TRANSFORMS } _{ idx } " ,
349- data = json .dumps (
350- obj = transform ,
351- default = patient_dataset .transforms_history .serialize
352- )
353- )
352+ patient_group .attrs .create (
353+ name = f"{ self .TRANSFORMS } _{ idx } " ,
354+ data = json .dumps (
355+ obj = transform ,
356+ default = patient_dataset .transforms_history .serialize
357+ )
358+ )
354359
355360 _logger .info (f"Progress : { patient_idx + 1 } /{ number_of_patients } patients added to database." )
356361
0 commit comments