platipy.imaging.projects.cardiac package#
Submodules#
platipy.imaging.projects.cardiac.run module#
- platipy.imaging.projects.cardiac.run.display_open_cardiac_zip_url_locations()#
- platipy.imaging.projects.cardiac.run.install_atlas_from_zipfile(zip_file_path, atlas_path)#
- platipy.imaging.projects.cardiac.run.install_hybrid_cardiac_from_zip(path_to_nnunet_zip, path_to_atlas_zip)#
- platipy.imaging.projects.cardiac.run.install_open_atlas(atlas_path)#
Fetch atlas from Zenodo and place into atlas_path
- Parameters:
atlas_path (pathlib.Path) – Path in which to place the atlas
- platipy.imaging.projects.cardiac.run.run_cardiac_segmentation(img, guide_structure=None, settings={'atlas_settings': {'atlas_id_list': ['03', '05', '08', '10', '11', '12', '13', '16', '24', '35'], 'atlas_image_format': 'Case_{0}/Images/Case_{0}_CROP.nii.gz', 'atlas_label_format': 'Case_{0}/Structures/Case_{0}_{1}_CROP.nii.gz', 'atlas_path': '/home/runner/.platipy/cardiac/test_atlas', 'atlas_structure_list': ['AORTICVALVE', 'ASCENDINGAORTA', 'LANTDESCARTERY', 'LCIRCUMFLEXARTERY', 'LCORONARYARTERY', 'LEFTATRIUM', 'LEFTVENTRICLE', 'MITRALVALVE', 'PULMONARYARTERY', 'PULMONICVALVE', 'RCORONARYARTERY', 'RIGHTATRIUM', 'RIGHTVENTRICLE', 'SVC', 'TRICUSPIDVALVE', 'WHOLEHEART'], 'crop_atlas_expansion_mm': (20, 20, 40), 'crop_atlas_to_structures': False, 'guide_structure_name': 'WHOLEHEART', 'superior_extension': 30}, 'auto_crop_target_image_settings': {'expansion_mm': [20, 20, 40]}, 'deformable_registration_settings': {'default_value': 0, 'isotropic_resample': True, 'iteration_staging': [200, 150, 100], 'ncores': 8, 'resolution_staging': [6, 3, 1.5], 'smoothing_sigmas': [0, 0, 0], 'verbose': False}, 'geometric_segmentation_settings': {'atlas_structure_names': {'atlas_ascending_aorta': 'A_Aorta', 'atlas_left_atrium': 'Atrium_L', 'atlas_left_ventricle': 'Ventricle_L', 'atlas_pulmonary_artery': 'A_Pulmonary', 'atlas_right_atrium': 'Atrium_R', 'atlas_right_ventricle': 'Ventricle_R', 'atlas_superior_vena_cava': 'V_Venacava_S', 'atlas_whole_heart': 'Heart'}, 'conduction_system_definitions': {'atrioventricular_node_radius_mm': 10, 'sinoatrial_node_radius_mm': 10}, 'geometric_name_suffix': '_GEOMETRIC', 'run_geometric_algorithms': True, 'valve_definitions': {'aortic_valve_thickness_mm': 10, 'mitral_valve_radius_mm': 15, 'mitral_valve_thickness_mm': 10, 'pulmonic_valve_thickness_mm': 10, 'tricuspid_valve_radius_mm': 15, 'tricuspid_valve_thickness_mm': 10}}, 'iar_settings': {'min_best_atlases': 5, 'outlier_factor': 1.5, 'outlier_method': 'iqr', 'project_on_sphere': False, 'reference_structure': False, 'smooth_distance_maps': True, 'smooth_sigma': 1, 'z_score_statistic': 'mad'}, 'label_fusion_settings': {'optimal_threshold': {'AORTICVALVE': 0.5, 'ASCENDINGAORTA': 0.44, 'LEFTATRIUM': 0.4, 'LEFTVENTRICLE': 0.45, 'MITRALVALVE': 0.5, 'PULMONARYARTERY': 0.46, 'PULMONICVALVE': 0.5, 'RIGHTATRIUM': 0.38, 'RIGHTVENTRICLE': 0.42, 'SVC': 0.44, 'TRICUSPIDVALVE': 0.5, 'WHOLEHEART': 0.5}, 'vote_params': None, 'vote_type': 'unweighted'}, 'linear_registration_settings': {'default_value': -1000, 'metric': 'mean_squares', 'number_of_iterations': 50, 'optimiser': 'gradient_descent_line_search', 'reg_method': 'affine', 'sampling_rate': 0.75, 'shrink_factors': [16, 8, 4], 'smooth_sigmas': [0, 0, 0], 'verbose': False}, 'postprocessing_settings': {'binaryfillhole_mm': 3, 'run_postprocessing': True, 'structures_for_binaryfillhole': ['Atrium_L', 'Ventricle_L', 'Atrium_R', 'Ventricle_R', 'A_Aorta', 'A_Pulmonary', 'V_Venacava_S', 'Heart'], 'structures_for_overlap_correction': ['Atrium_L', 'Ventricle_L', 'Atrium_R', 'Ventricle_R', 'A_Aorta', 'A_Pulmonary', 'V_Venacava_S']}, 'return_as_cropped': False, 'return_atlas_guide_structure': False, 'return_proba_as_contours': False, 'structure_guided_registration_settings': {'default_value': 0, 'isotropic_resample': True, 'iteration_staging': [50, 50, 50], 'ncores': 8, 'resolution_staging': [16, 8, 2], 'smoothing_sigmas': [0, 0, 0], 'verbose': False}, 'vessel_spline_settings': {'scan_direction_dict': {'LANTDESCARTERY': 'z', 'LCIRCUMFLEXARTERY': 'z', 'LCORONARYARTERY': 'x', 'RCORONARYARTERY': 'z'}, 'stop_condition_type_dict': {'LANTDESCARTERY': 'count', 'LCIRCUMFLEXARTERY': 'count', 'LCORONARYARTERY': 'count', 'RCORONARYARTERY': 'count'}, 'stop_condition_value_dict': {'LANTDESCARTERY': 2, 'LCIRCUMFLEXARTERY': 2, 'LCORONARYARTERY': 2, 'RCORONARYARTERY': 2}, 'vessel_name_list': ['LANTDESCARTERY', 'LCIRCUMFLEXARTERY', 'LCORONARYARTERY', 'RCORONARYARTERY'], 'vessel_radius_mm_dict': {'LANTDESCARTERY': 2, 'LCIRCUMFLEXARTERY': 2, 'LCORONARYARTERY': 2, 'RCORONARYARTERY': 2}}})#
Runs the atlas-based cardiac segmentation
- Parameters:
img (sitk.Image) –
settings (dict, optional) – Dictionary containing settings for algorithm. Defaults to default_settings.
- Returns:
Dictionary containing output of segmentation
- Return type:
dict
- platipy.imaging.projects.cardiac.run.run_hybrid_segmentation(img, settings={'cardiac_settings': {'atlas_settings': {'atlas_id_list': ['LCTSC-Test-S2-201', 'LCTSC-Test-S2-203', 'LCTSC-Test-S3-201', 'LUNG1-002', 'LUNG1-009', 'LUNG1-021', 'LUNG1-067', 'LUNG1-226'], 'atlas_image_format': '{0}/IMAGES/CT.nii.gz', 'atlas_label_format': '{0}/STRUCTURES/{1}.nii.gz', 'atlas_path': '/home/runner/.platipy/cardiac/test_atlas', 'atlas_structure_list': ['Atrium_L', 'Ventricle_L', 'Atrium_R', 'Ventricle_R', 'A_Aorta', 'A_Pulmonary', 'V_Venacava_S', 'A_LAD', 'A_Coronary_L', 'A_Cflx', 'A_Coronary_R', 'Heart'], 'crop_atlas_expansion_mm': (50, 50, 50), 'crop_atlas_to_structures': True, 'guide_structure_name': 'Heart', 'superior_extension': 30}, 'auto_crop_target_image_settings': {'expansion_mm': [20, 20, 40]}, 'deformable_registration_settings': {'default_value': 0, 'isotropic_resample': True, 'iteration_staging': [200, 150, 100], 'ncores': 8, 'resolution_staging': [6, 3, 1.5], 'smoothing_sigmas': [0, 0, 0], 'verbose': False}, 'geometric_segmentation_settings': {'atlas_structure_names': {'atlas_ascending_aorta': 'A_Aorta', 'atlas_left_atrium': 'Atrium_L', 'atlas_left_ventricle': 'Ventricle_L', 'atlas_pulmonary_artery': 'A_Pulmonary', 'atlas_right_atrium': 'Atrium_R', 'atlas_right_ventricle': 'Ventricle_R', 'atlas_superior_vena_cava': 'V_Venacava_S', 'atlas_whole_heart': 'Heart'}, 'conduction_system_definitions': {'atrioventricular_node_radius_mm': 10, 'sinoatrial_node_radius_mm': 10}, 'geometric_name_suffix': '_GEOMETRIC', 'run_geometric_algorithms': True, 'valve_definitions': {'aortic_valve_thickness_mm': 10, 'mitral_valve_radius_mm': 15, 'mitral_valve_thickness_mm': 10, 'pulmonic_valve_thickness_mm': 10, 'tricuspid_valve_radius_mm': 15, 'tricuspid_valve_thickness_mm': 10}}, 'iar_settings': {'min_best_atlases': 5, 'outlier_factor': 1.5, 'outlier_method': 'iqr', 'project_on_sphere': False, 'reference_structure': False, 'smooth_distance_maps': True, 'smooth_sigma': 1, 'z_score_statistic': 'mad'}, 'label_fusion_settings': {'optimal_threshold': {'A_Aorta': 0.5, 'A_Pulmonary': 0.5, 'Atrium_L': 0.5, 'Atrium_R': 0.5, 'Heart': 0.5, 'V_Venacava_S': 0.5, 'Ventricle_L': 0.5, 'Ventricle_R': 0.5}, 'vote_params': None, 'vote_type': 'unweighted'}, 'linear_registration_settings': {'default_value': -1000, 'metric': 'mean_squares', 'number_of_iterations': 50, 'optimiser': 'gradient_descent_line_search', 'reg_method': 'affine', 'sampling_rate': 0.75, 'shrink_factors': [16, 8, 4], 'smooth_sigmas': [0, 0, 0], 'verbose': False}, 'postprocessing_settings': {'binaryfillhole_mm': 3, 'run_postprocessing': True, 'structures_for_binaryfillhole': ['Atrium_L', 'Ventricle_L', 'Atrium_R', 'Ventricle_R', 'A_Aorta', 'A_Pulmonary', 'V_Venacava_S', 'Heart'], 'structures_for_overlap_correction': ['Atrium_L', 'Ventricle_L', 'Atrium_R', 'Ventricle_R', 'A_Aorta', 'A_Pulmonary', 'V_Venacava_S']}, 'return_as_cropped': False, 'return_atlas_guide_structure': False, 'return_proba_as_contours': True, 'structure_guided_registration_settings': {'default_value': 0, 'isotropic_resample': True, 'iteration_staging': [50, 50, 50], 'ncores': 8, 'resolution_staging': [16, 8, 2], 'smoothing_sigmas': [0, 0, 0], 'verbose': False}, 'vessel_spline_settings': {'scan_direction_dict': {'A_Cflx': 'z', 'A_Coronary_L': 'x', 'A_Coronary_R': 'z', 'A_LAD': 'z'}, 'stop_condition_type_dict': {'A_Cflx': 'count', 'A_Coronary_L': 'count', 'A_Coronary_R': 'count', 'A_LAD': 'count'}, 'stop_condition_value_dict': {'A_Cflx': 2, 'A_Coronary_L': 2, 'A_Coronary_R': 2, 'A_LAD': 2}, 'vessel_name_list': ['A_LAD', 'A_Cflx', 'A_Coronary_L', 'A_Coronary_R'], 'vessel_radius_mm_dict': {'A_Cflx': 2, 'A_Coronary_L': 2, 'A_Coronary_R': 2, 'A_LAD': 2}}}, 'fetch_open_atlas': True, 'nnunet_settings': {'all_in_gpu': None, 'cascade_trainer_class_name': 'nnUNetTrainerV2CascadeFullRes', 'chk': 'model_final_checkpoint', 'disable_mixed_precision': False, 'disable_tta': False, 'folds': 'all', 'lowres_segmentations': None, 'model': '3d_lowres', 'num_threads_nifti_save': 2, 'num_threads_preprocessing': 6, 'task': 'Task400_OPEN_HEART_1FOLD', 'trainer_class_name': 'nnUNetTrainerV2'}})#
Runs the hybrid cardiac segmentation
- Parameters:
img (sitk.Image) –
settings (dict, optional) – Dictionary containing settings for algorithm. Defaults to HYBRID_SETTINGS_DEFAULTS.
- Returns:
Dictionary containing output of segmentation
- Return type:
dict
platipy.imaging.projects.cardiac.service module#
- platipy.imaging.projects.cardiac.service.cardiac_service(data_objects, working_dir, settings)#
Implements the platipy framework to provide cardiac atlas based segmentation.
- platipy.imaging.projects.cardiac.service.cardiac_structure_guided_service(data_objects, working_dir, settings)#
Runs the structure guided cardiac segmentation service