diff --git a/.readthedocs.yaml b/.readthedocs.yaml index ebe1267..e86c5cd 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,5 +1,9 @@ version: 2 +sphinx: + # Path to Sphinx configuration file. + configuration: docs/conf.py + # Set the version of Python build: os: ubuntu-20.04 diff --git a/MEDimage/MEDscan.py b/MEDiml/MEDscan.py similarity index 100% rename from MEDimage/MEDscan.py rename to MEDiml/MEDscan.py diff --git a/MEDimage/__init__.py b/MEDiml/__init__.py similarity index 100% rename from MEDimage/__init__.py rename to MEDiml/__init__.py diff --git a/MEDimage/biomarkers/BatchExtractor.py b/MEDiml/biomarkers/BatchExtractor.py similarity index 92% rename from MEDimage/biomarkers/BatchExtractor.py rename to MEDiml/biomarkers/BatchExtractor.py index f5d3c77..c08f699 100644 --- a/MEDimage/biomarkers/BatchExtractor.py +++ b/MEDiml/biomarkers/BatchExtractor.py @@ -15,7 +15,7 @@ import ray from tqdm import trange -import MEDimage +import MEDiml class BatchExtractor(object): @@ -47,7 +47,7 @@ def __init__( def __load_and_process_params(self) -> Dict: """Load and process the computing & batch parameters from JSON file""" # Load json parameters - im_params = MEDimage.utils.json_utils.load_json(self._path_params) + im_params = MEDiml.utils.json_utils.load_json(self._path_params) # Update class attributes self.roi_types.extend(im_params['roi_types']) @@ -70,7 +70,7 @@ def __compute_radiomics_one_patient( Computes all radiomics features (Texture & Non-texture) for one patient/scan Args: - name_patient(str): scan or patient full name. It has to respect the MEDimage naming convention: + name_patient(str): scan or patient full name. It has to respect the MEDiml naming convention: PatientID__ImagingScanName.ImagingModality.npy roi_name(str): name of the ROI that will be used in computation. im_params(Dict): Dict of parameters/settings that will be used in the processing and computation. @@ -102,7 +102,7 @@ def __compute_radiomics_one_patient( # Load MEDscan instance try: with open(self._path_read / name_patient, 'rb') as f: medscan = pickle.load(f) - medscan = MEDimage.MEDscan(medscan) + medscan = MEDiml.MEDscan(medscan) except Exception as e: print(f"\n ERROR LOADING PATIENT {name_patient}:\n {e}") return None @@ -114,7 +114,7 @@ def __compute_radiomics_one_patient( # Get ROI (region of interest) logging.info("\n--> Extraction of ROI mask:") try: - vol_obj_init, roi_obj_init = MEDimage.processing.get_roi_from_indexes( + vol_obj_init, roi_obj_init = MEDiml.processing.get_roi_from_indexes( medscan, name_roi=roi_name, box_string=medscan.params.process.box_string @@ -130,7 +130,7 @@ def __compute_radiomics_one_patient( # Interpolation # Intensity Mask - vol_obj = MEDimage.processing.interp_volume( + vol_obj = MEDiml.processing.interp_volume( medscan=medscan, vol_obj_s=vol_obj_init, vox_dim=medscan.params.process.scale_non_text, @@ -141,7 +141,7 @@ def __compute_radiomics_one_patient( box_string=medscan.params.process.box_string ) # Morphological Mask - roi_obj_morph = MEDimage.processing.interp_volume( + roi_obj_morph = MEDiml.processing.interp_volume( medscan=medscan, vol_obj_s=roi_obj_init, vox_dim=medscan.params.process.scale_non_text, @@ -155,14 +155,14 @@ def __compute_radiomics_one_patient( # Re-segmentation # Intensity mask range re-segmentation roi_obj_int = deepcopy(roi_obj_morph) - roi_obj_int.data = MEDimage.processing.range_re_seg( + roi_obj_int.data = MEDiml.processing.range_re_seg( vol=vol_obj.data, roi=roi_obj_int.data, im_range=medscan.params.process.im_range ) # Intensity mask outlier re-segmentation roi_obj_int.data = np.logical_and( - MEDimage.processing.outlier_re_seg( + MEDiml.processing.outlier_re_seg( vol=vol_obj.data, roi=roi_obj_int.data, outliers=medscan.params.process.outliers @@ -182,14 +182,14 @@ def __compute_radiomics_one_patient( if medscan.params.filter.filter_type.lower() == 'textural': raise ValueError('For textural filtering, please use the BatchExtractorTexturalFilters class.') try: - vol_obj = MEDimage.filters.apply_filter(medscan, vol_obj) + vol_obj = MEDiml.filters.apply_filter(medscan, vol_obj) except Exception as e: logging.error(f'PROBLEM WITH LINEAR FILTERING: {e}') return log_file # ROI Extraction : try: - vol_int_re = MEDimage.processing.roi_extract( + vol_int_re = MEDiml.processing.roi_extract( vol=vol_obj.data, roi=roi_obj_int.data ) @@ -208,7 +208,7 @@ def __compute_radiomics_one_patient( # Morphological features extraction try: if medscan.params.radiomics.extract['Morph']: - morph = MEDimage.biomarkers.morph.extract_all( + morph = MEDiml.biomarkers.morph.extract_all( vol=vol_obj.data, mask_int=roi_obj_int.data, mask_morph=roi_obj_morph.data, @@ -224,7 +224,7 @@ def __compute_radiomics_one_patient( # Local intensity features extraction try: if medscan.params.radiomics.extract['LocalIntensity']: - local_intensity = MEDimage.biomarkers.local_intensity.extract_all( + local_intensity = MEDiml.biomarkers.local_intensity.extract_all( img_obj=vol_obj.data, roi_obj=roi_obj_int.data, res=medscan.params.process.scale_non_text, @@ -239,7 +239,7 @@ def __compute_radiomics_one_patient( # statistical features extraction try: if medscan.params.radiomics.extract['Stats']: - stats = MEDimage.biomarkers.stats.extract_all( + stats = MEDiml.biomarkers.stats.extract_all( vol=vol_int_re, intensity_type=medscan.params.process.intensity_type ) @@ -250,7 +250,7 @@ def __compute_radiomics_one_patient( stats = None # Intensity histogram equalization of the imaging volume - vol_quant_re, _ = MEDimage.processing.discretize( + vol_quant_re, _ = MEDiml.processing.discretize( vol_re=vol_int_re, discr_type=medscan.params.process.ih['type'], n_q=medscan.params.process.ih['val'], @@ -260,7 +260,7 @@ def __compute_radiomics_one_patient( # Intensity histogram features extraction try: if medscan.params.radiomics.extract['IntensityHistogram']: - int_hist = MEDimage.biomarkers.intensity_histogram.extract_all( + int_hist = MEDiml.biomarkers.intensity_histogram.extract_all( vol=vol_quant_re ) else: @@ -272,7 +272,7 @@ def __compute_radiomics_one_patient( # Intensity histogram equalization of the imaging volume if medscan.params.process.ivh and 'type' in medscan.params.process.ivh and 'val' in medscan.params.process.ivh: if medscan.params.process.ivh['type'] and medscan.params.process.ivh['val']: - vol_quant_re, wd = MEDimage.processing.discretize( + vol_quant_re, wd = MEDiml.processing.discretize( vol_re=vol_int_re, discr_type=medscan.params.process.ivh['type'], n_q=medscan.params.process.ivh['val'], @@ -285,7 +285,7 @@ def __compute_radiomics_one_patient( # Intensity volume histogram features extraction if medscan.params.radiomics.extract['IntensityVolumeHistogram']: - int_vol_hist = MEDimage.biomarkers.int_vol_hist.extract_all( + int_vol_hist = MEDiml.biomarkers.int_vol_hist.extract_all( medscan=medscan, vol=vol_quant_re, vol_int_re=vol_int_re, @@ -310,7 +310,7 @@ def __compute_radiomics_one_patient( # Interpolation # Intensity Mask - vol_obj = MEDimage.processing.interp_volume( + vol_obj = MEDiml.processing.interp_volume( medscan=medscan, vol_obj_s=vol_obj_init, vox_dim=medscan.params.process.scale_text[s], @@ -321,7 +321,7 @@ def __compute_radiomics_one_patient( box_string=medscan.params.process.box_string ) # Morphological Mask - roi_obj_morph = MEDimage.processing.interp_volume( + roi_obj_morph = MEDiml.processing.interp_volume( medscan=medscan, vol_obj_s=roi_obj_init, vox_dim=medscan.params.process.scale_text[s], @@ -335,14 +335,14 @@ def __compute_radiomics_one_patient( # Re-segmentation # Intensity mask range re-segmentation roi_obj_int = deepcopy(roi_obj_morph) - roi_obj_int.data = MEDimage.processing.range_re_seg( + roi_obj_int.data = MEDiml.processing.range_re_seg( vol=vol_obj.data, roi=roi_obj_int.data, im_range=medscan.params.process.im_range ) # Intensity mask outlier re-segmentation roi_obj_int.data = np.logical_and( - MEDimage.processing.outlier_re_seg( + MEDiml.processing.outlier_re_seg( vol=vol_obj.data, roi=roi_obj_int.data, outliers=medscan.params.process.outliers @@ -355,7 +355,7 @@ def __compute_radiomics_one_patient( if medscan.params.filter.filter_type.lower() == 'textural': raise ValueError('For textural filtering, please use the BatchExtractorTexturalFilters class.') try: - vol_obj = MEDimage.filters.apply_filter(medscan, vol_obj) + vol_obj = MEDiml.filters.apply_filter(medscan, vol_obj) except Exception as e: logging.error(f'PROBLEM WITH LINEAR FILTERING: {e}') return log_file @@ -379,13 +379,13 @@ def __compute_radiomics_one_patient( medscan.init_tf_calculation(algo=a, gl=n, scale=s) # ROI Extraction : - vol_int_re = MEDimage.processing.roi_extract( + vol_int_re = MEDiml.processing.roi_extract( vol=vol_obj.data, roi=roi_obj_int.data) # Discretisation : try: - vol_quant_re, _ = MEDimage.processing.discretize( + vol_quant_re, _ = MEDiml.processing.discretize( vol_re=vol_int_re, discr_type=medscan.params.process.algo[a], n_q=medscan.params.process.gray_levels[a][n], @@ -398,7 +398,7 @@ def __compute_radiomics_one_patient( # GLCM features extraction try: if medscan.params.radiomics.extract['GLCM']: - glcm = MEDimage.biomarkers.glcm.extract_all( + glcm = MEDiml.biomarkers.glcm.extract_all( vol=vol_quant_re, dist_correction=medscan.params.radiomics.glcm.dist_correction) else: @@ -410,7 +410,7 @@ def __compute_radiomics_one_patient( # GLRLM features extraction try: if medscan.params.radiomics.extract['GLRLM']: - glrlm = MEDimage.biomarkers.glrlm.extract_all( + glrlm = MEDiml.biomarkers.glrlm.extract_all( vol=vol_quant_re, dist_correction=medscan.params.radiomics.glrlm.dist_correction) else: @@ -422,7 +422,7 @@ def __compute_radiomics_one_patient( # GLSZM features extraction try: if medscan.params.radiomics.extract['GLSZM']: - glszm = MEDimage.biomarkers.glszm.extract_all( + glszm = MEDiml.biomarkers.glszm.extract_all( vol=vol_quant_re) else: glszm = None @@ -433,7 +433,7 @@ def __compute_radiomics_one_patient( # GLDZM features extraction try: if medscan.params.radiomics.extract['GLDZM']: - gldzm = MEDimage.biomarkers.gldzm.extract_all( + gldzm = MEDiml.biomarkers.gldzm.extract_all( vol_int=vol_quant_re, mask_morph=roi_obj_morph.data) else: @@ -445,7 +445,7 @@ def __compute_radiomics_one_patient( # NGTDM features extraction try: if medscan.params.radiomics.extract['NGTDM']: - ngtdm = MEDimage.biomarkers.ngtdm.extract_all( + ngtdm = MEDiml.biomarkers.ngtdm.extract_all( vol=vol_quant_re, dist_correction=medscan.params.radiomics.ngtdm.dist_correction) else: @@ -457,7 +457,7 @@ def __compute_radiomics_one_patient( # NGLDM features extraction try: if medscan.params.radiomics.extract['NGLDM']: - ngldm = MEDimage.biomarkers.ngldm.extract_all( + ngldm = MEDiml.biomarkers.ngldm.extract_all( vol=vol_quant_re) else: ngldm = None @@ -556,8 +556,8 @@ def __compute_radiomics_tables( wildcard = '*_' + scan + '(' + roi_type + ')*.json' # Create radiomics table - radiomics_table_dict = MEDimage.utils.create_radiomics_table( - MEDimage.utils.get_file_paths(self._path_save / f'features({roi_label})', wildcard), + radiomics_table_dict = MEDiml.utils.create_radiomics_table( + MEDiml.utils.get_file_paths(self._path_save / f'features({roi_label})', wildcard), im_space, log_file ) @@ -568,7 +568,7 @@ def __compute_radiomics_tables( np.save(save_path, [radiomics_table_dict]) # Create CSV table and Definitions - MEDimage.utils.write_radiomics_csv(save_path) + MEDiml.utils.write_radiomics_csv(save_path) logging.info(f"DONE\n {time() - start}\n") @@ -687,13 +687,13 @@ def __batch_all_tables(self, im_params: Dict): for r in range(0, n_roi_types): label = self.roi_type_labels[r] wildcard = '*' + label + '*.json' - file_paths = MEDimage.utils.get_file_paths(self._path_save / f'features({self.roi_types[r]})', wildcard) + file_paths = MEDiml.utils.get_file_paths(self._path_save / f'features({self.roi_types[r]})', wildcard) n_files = len(file_paths) scans = [0] * n_files modalities = [0] * n_files for f in range(0, n_files): rad_file_name = file_paths[f].stem - scans[f] = MEDimage.utils.get_scan_name_from_rad_name(rad_file_name) + scans[f] = MEDiml.utils.get_scan_name_from_rad_name(rad_file_name) modalities[f] = rad_file_name.split('.')[1] scans = s = (np.unique(np.array(scans))).tolist() n_scans = len(scans) @@ -702,12 +702,12 @@ def __batch_all_tables(self, im_params: Dict): scan = scans[s] modality = modalities[s] wildcard = '*' + scan + '(' + label + ')*.json' - file_paths = MEDimage.utils.get_file_paths(self._path_save / f'features({self.roi_types[r]})', wildcard) + file_paths = MEDiml.utils.get_file_paths(self._path_save / f'features({self.roi_types[r]})', wildcard) n_files = len(file_paths) # Finding the images spaces for a test file (assuming that all # files for a given scan and roi_type_label have the same image spaces - radiomics = MEDimage.utils.json_utils.load_json(file_paths[0]) + radiomics = MEDiml.utils.json_utils.load_json(file_paths[0]) im_spaces = [key for key in radiomics.keys()] im_spaces = im_spaces[:-1] n_im_spaces = len(im_spaces) diff --git a/MEDimage/biomarkers/BatchExtractorTexturalFilters.py b/MEDiml/biomarkers/BatchExtractorTexturalFilters.py similarity index 93% rename from MEDimage/biomarkers/BatchExtractorTexturalFilters.py rename to MEDiml/biomarkers/BatchExtractorTexturalFilters.py index 4403622..6377532 100644 --- a/MEDimage/biomarkers/BatchExtractorTexturalFilters.py +++ b/MEDiml/biomarkers/BatchExtractorTexturalFilters.py @@ -15,7 +15,7 @@ import ray from tqdm import trange -import MEDimage +import MEDiml class BatchExtractorTexturalFilters(object): @@ -72,7 +72,7 @@ def __init__( def __load_and_process_params(self) -> Dict: """Load and process the computing & batch parameters from JSON file""" # Load json parameters - im_params = MEDimage.utils.json_utils.load_json(self._path_params) + im_params = MEDiml.utils.json_utils.load_json(self._path_params) # Update class attributes self.roi_types.extend(im_params['roi_types']) @@ -95,7 +95,7 @@ def __compute_radiomics_one_patient( Computes all radiomics features (Texture & Non-texture) for one patient/scan Args: - name_patient(str): scan or patient full name. It has to respect the MEDimage naming convention: + name_patient(str): scan or patient full name. It has to respect the MEDiml naming convention: PatientID__ImagingScanName.ImagingModality.npy roi_name(str): name of the ROI that will be used in computation. im_params(Dict): Dict of parameters/settings that will be used in the processing and computation. @@ -136,7 +136,7 @@ def __compute_radiomics_one_patient( # Load MEDscan instance try: with open(self._path_read / name_patient, 'rb') as f: medscan = pickle.load(f) - medscan = MEDimage.MEDscan(medscan) + medscan = MEDiml.MEDscan(medscan) except Exception as e: logging.error(f"\n ERROR LOADING PATIENT {name_patient}:\n {e}") return None @@ -148,7 +148,7 @@ def __compute_radiomics_one_patient( # Get ROI (region of interest) logging.info("\n--> Extraction of ROI mask:") try: - vol_obj_init, roi_obj_init = MEDimage.processing.get_roi_from_indexes( + vol_obj_init, roi_obj_init = MEDiml.processing.get_roi_from_indexes( medscan, name_roi=roi_name, box_string=medscan.params.process.box_string @@ -164,7 +164,7 @@ def __compute_radiomics_one_patient( # Interpolation # Intensity Mask - vol_obj = MEDimage.processing.interp_volume( + vol_obj = MEDiml.processing.interp_volume( medscan=medscan, vol_obj_s=vol_obj_init, vox_dim=medscan.params.process.scale_non_text, @@ -175,7 +175,7 @@ def __compute_radiomics_one_patient( box_string=medscan.params.process.box_string ) # Morphological Mask - roi_obj_morph = MEDimage.processing.interp_volume( + roi_obj_morph = MEDiml.processing.interp_volume( medscan=medscan, vol_obj_s=roi_obj_init, vox_dim=medscan.params.process.scale_non_text, @@ -189,14 +189,14 @@ def __compute_radiomics_one_patient( # Re-segmentation # Intensity mask range re-segmentation roi_obj_int = deepcopy(roi_obj_morph) - roi_obj_int.data = MEDimage.processing.range_re_seg( + roi_obj_int.data = MEDiml.processing.range_re_seg( vol=vol_obj.data, roi=roi_obj_int.data, im_range=medscan.params.process.im_range ) # Intensity mask outlier re-segmentation roi_obj_int.data = np.logical_and( - MEDimage.processing.outlier_re_seg( + MEDiml.processing.outlier_re_seg( vol=vol_obj.data, roi=roi_obj_int.data, outliers=medscan.params.process.outliers @@ -216,7 +216,7 @@ def __compute_radiomics_one_patient( # ROI Extraction : try: - vol_int_re = MEDimage.processing.roi_extract( + vol_int_re = MEDiml.processing.roi_extract( vol=vol_obj.data, roi=roi_obj_int.data ) @@ -228,7 +228,7 @@ def __compute_radiomics_one_patient( try: if medscan.params.process.user_set_min_value is None: medscan.params.process.user_set_min_value = np.nanmin(vol_int_re) - vol_obj_all_features = MEDimage.filters.apply_filter( + vol_obj_all_features = MEDiml.filters.apply_filter( medscan, vol_int_re, user_set_min_val=medscan.params.process.user_set_min_value @@ -311,7 +311,7 @@ def __compute_radiomics_one_patient( @ray.remote def __compute_radiomics_filtered_volume( self, - medscan: MEDimage.MEDscan, + medscan: MEDiml.MEDscan, vol_obj, roi_obj_int, roi_obj_morph, @@ -338,7 +338,7 @@ def __compute_radiomics_filtered_volume( # Morphological features extraction try: - morph = MEDimage.biomarkers.morph.extract_all( + morph = MEDiml.biomarkers.morph.extract_all( vol=vol_obj.data, mask_int=roi_obj_int.data, mask_morph=roi_obj_morph.data, @@ -351,7 +351,7 @@ def __compute_radiomics_filtered_volume( # Local intensity features extraction try: - local_intensity = MEDimage.biomarkers.local_intensity.extract_all( + local_intensity = MEDiml.biomarkers.local_intensity.extract_all( img_obj=vol_obj.data, roi_obj=roi_obj_int.data, res=medscan.params.process.scale_non_text, @@ -363,7 +363,7 @@ def __compute_radiomics_filtered_volume( # statistical features extraction try: - stats = MEDimage.biomarkers.stats.extract_all( + stats = MEDiml.biomarkers.stats.extract_all( vol=vol_int_re, intensity_type=medscan.params.process.intensity_type ) @@ -372,7 +372,7 @@ def __compute_radiomics_filtered_volume( stats = None # Intensity histogram equalization of the imaging volume - vol_quant_re, _ = MEDimage.processing.discretize( + vol_quant_re, _ = MEDiml.processing.discretize( vol_re=vol_int_re, discr_type=medscan.params.process.ih['type'], n_q=medscan.params.process.ih['val'], @@ -381,7 +381,7 @@ def __compute_radiomics_filtered_volume( # Intensity histogram features extraction try: - int_hist = MEDimage.biomarkers.intensity_histogram.extract_all( + int_hist = MEDiml.biomarkers.intensity_histogram.extract_all( vol=vol_quant_re ) except Exception as e: @@ -391,7 +391,7 @@ def __compute_radiomics_filtered_volume( # Intensity histogram equalization of the imaging volume if medscan.params.process.ivh and 'type' in medscan.params.process.ivh and 'val' in medscan.params.process.ivh: if medscan.params.process.ivh['type'] and medscan.params.process.ivh['val']: - vol_quant_re, wd = MEDimage.processing.discretize( + vol_quant_re, wd = MEDiml.processing.discretize( vol_re=vol_int_re, discr_type=medscan.params.process.ivh['type'], n_q=medscan.params.process.ivh['val'], @@ -404,7 +404,7 @@ def __compute_radiomics_filtered_volume( # Intensity volume histogram features extraction try: - int_vol_hist = MEDimage.biomarkers.int_vol_hist.extract_all( + int_vol_hist = MEDiml.biomarkers.int_vol_hist.extract_all( medscan=medscan, vol=vol_quant_re, vol_int_re=vol_int_re, @@ -449,7 +449,7 @@ def __compute_radiomics_filtered_volume( # Discretisation : try: - vol_quant_re, _ = MEDimage.processing.discretize( + vol_quant_re, _ = MEDiml.processing.discretize( vol_re=vol_int_re, discr_type=medscan.params.process.algo[a], n_q=medscan.params.process.gray_levels[a][n], @@ -461,7 +461,7 @@ def __compute_radiomics_filtered_volume( # GLCM features extraction try: - glcm = MEDimage.biomarkers.glcm.extract_all( + glcm = MEDiml.biomarkers.glcm.extract_all( vol=vol_quant_re, dist_correction=medscan.params.radiomics.glcm.dist_correction ) @@ -471,7 +471,7 @@ def __compute_radiomics_filtered_volume( # GLRLM features extraction try: - glrlm = MEDimage.biomarkers.glrlm.extract_all( + glrlm = MEDiml.biomarkers.glrlm.extract_all( vol=vol_quant_re, dist_correction=medscan.params.radiomics.glrlm.dist_correction ) @@ -481,14 +481,14 @@ def __compute_radiomics_filtered_volume( # GLSZM features extraction try: - glszm = MEDimage.biomarkers.glszm.extract_all(vol=vol_quant_re) + glszm = MEDiml.biomarkers.glszm.extract_all(vol=vol_quant_re) except Exception as e: logging.error(f'PROBLEM WITH COMPUTATION OF GLSZM FEATURES {e}') glszm = None # GLDZM features extraction try: - gldzm = MEDimage.biomarkers.gldzm.extract_all( + gldzm = MEDiml.biomarkers.gldzm.extract_all( vol_int=vol_quant_re, mask_morph=roi_obj_morph.data ) @@ -498,7 +498,7 @@ def __compute_radiomics_filtered_volume( # NGTDM features extraction try: - ngtdm = MEDimage.biomarkers.ngtdm.extract_all( + ngtdm = MEDiml.biomarkers.ngtdm.extract_all( vol=vol_quant_re, dist_correction=medscan.params.radiomics.ngtdm.dist_correction ) @@ -508,7 +508,7 @@ def __compute_radiomics_filtered_volume( # NGLDM features extraction try: - ngldm = MEDimage.biomarkers.ngldm.extract_all(vol=vol_quant_re) + ngldm = MEDiml.biomarkers.ngldm.extract_all(vol=vol_quant_re) except Exception as e: logging.error(f'PROBLEM WITH COMPUTATION OF NGLDM FEATURES {e}') ngldm = None @@ -605,8 +605,8 @@ def __compute_radiomics_tables( wildcard = '*_' + scan + '(' + roi_type + ')*.json' # Create radiomics table - radiomics_table_dict = MEDimage.utils.create_radiomics_table( - MEDimage.utils.get_file_paths(self._path_save / f'features({roi_label})', wildcard), + radiomics_table_dict = MEDiml.utils.create_radiomics_table( + MEDiml.utils.get_file_paths(self._path_save / f'features({roi_label})', wildcard), im_space, log_file ) @@ -617,7 +617,7 @@ def __compute_radiomics_tables( np.save(save_path, [radiomics_table_dict]) # Create CSV table and Definitions - MEDimage.utils.write_radiomics_csv(save_path) + MEDiml.utils.write_radiomics_csv(save_path) logging.info(f"DONE\n {time() - start}\n") @@ -740,13 +740,13 @@ def __batch_all_tables(self, im_params: Dict): label = self.roi_type_labels[r] wildcard = '*' + label + '*.json' roi_type = self.roi_types[r] + '_' + self.glcm_features[f_idx] - file_paths = MEDimage.utils.get_file_paths(self._path_save / f'features({roi_type})', wildcard) + file_paths = MEDiml.utils.get_file_paths(self._path_save / f'features({roi_type})', wildcard) n_files = len(file_paths) scans = [0] * n_files modalities = [0] * n_files for f in range(0, n_files): rad_file_name = file_paths[f].stem - scans[f] = MEDimage.utils.get_scan_name_from_rad_name(rad_file_name) + scans[f] = MEDiml.utils.get_scan_name_from_rad_name(rad_file_name) modalities[f] = rad_file_name.split('.')[1] scans = s = (np.unique(np.array(scans))).tolist() n_scans = len(scans) @@ -755,12 +755,12 @@ def __batch_all_tables(self, im_params: Dict): scan = scans[s] modality = modalities[s] wildcard = '*' + scan + '(' + label + ')*.json' - file_paths = MEDimage.utils.get_file_paths(self._path_save / f'features({roi_type})', wildcard) + file_paths = MEDiml.utils.get_file_paths(self._path_save / f'features({roi_type})', wildcard) n_files = len(file_paths) # Finding the images spaces for a test file (assuming that all # files for a given scan and roi_type_label have the same image spaces - radiomics = MEDimage.utils.json_utils.load_json(file_paths[0]) + radiomics = MEDiml.utils.json_utils.load_json(file_paths[0]) im_spaces = [key for key in radiomics.keys()] im_spaces = im_spaces[:-1] n_im_spaces = len(im_spaces) diff --git a/MEDimage/biomarkers/__init__.py b/MEDiml/biomarkers/__init__.py similarity index 100% rename from MEDimage/biomarkers/__init__.py rename to MEDiml/biomarkers/__init__.py diff --git a/MEDimage/biomarkers/diagnostics.py b/MEDiml/biomarkers/diagnostics.py similarity index 100% rename from MEDimage/biomarkers/diagnostics.py rename to MEDiml/biomarkers/diagnostics.py diff --git a/MEDimage/biomarkers/get_oriented_bound_box.py b/MEDiml/biomarkers/get_oriented_bound_box.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/get_oriented_bound_box.py rename to MEDiml/biomarkers/get_oriented_bound_box.py diff --git a/MEDimage/biomarkers/glcm.py b/MEDiml/biomarkers/glcm.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/glcm.py rename to MEDiml/biomarkers/glcm.py diff --git a/MEDimage/biomarkers/gldzm.py b/MEDiml/biomarkers/gldzm.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/gldzm.py rename to MEDiml/biomarkers/gldzm.py diff --git a/MEDimage/biomarkers/glrlm.py b/MEDiml/biomarkers/glrlm.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/glrlm.py rename to MEDiml/biomarkers/glrlm.py diff --git a/MEDimage/biomarkers/glszm.py b/MEDiml/biomarkers/glszm.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/glszm.py rename to MEDiml/biomarkers/glszm.py diff --git a/MEDimage/biomarkers/int_vol_hist.py b/MEDiml/biomarkers/int_vol_hist.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/int_vol_hist.py rename to MEDiml/biomarkers/int_vol_hist.py diff --git a/MEDimage/biomarkers/intensity_histogram.py b/MEDiml/biomarkers/intensity_histogram.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/intensity_histogram.py rename to MEDiml/biomarkers/intensity_histogram.py diff --git a/MEDimage/biomarkers/local_intensity.py b/MEDiml/biomarkers/local_intensity.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/local_intensity.py rename to MEDiml/biomarkers/local_intensity.py diff --git a/MEDimage/biomarkers/morph.py b/MEDiml/biomarkers/morph.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/morph.py rename to MEDiml/biomarkers/morph.py diff --git a/MEDimage/biomarkers/ngldm.py b/MEDiml/biomarkers/ngldm.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/ngldm.py rename to MEDiml/biomarkers/ngldm.py diff --git a/MEDimage/biomarkers/ngtdm.py b/MEDiml/biomarkers/ngtdm.py old mode 100755 new mode 100644 similarity index 100% rename from MEDimage/biomarkers/ngtdm.py rename to MEDiml/biomarkers/ngtdm.py diff --git a/MEDimage/biomarkers/stats.py b/MEDiml/biomarkers/stats.py old mode 100755 new mode 100644 similarity index 97% rename from MEDimage/biomarkers/stats.py rename to MEDiml/biomarkers/stats.py index d6cb220..1dc0c3e --- a/MEDimage/biomarkers/stats.py +++ b/MEDiml/biomarkers/stats.py @@ -1,373 +1,373 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import numpy as np -from scipy.stats import iqr, kurtosis, skew, scoreatpercentile, variation - - -def extract_all(vol: np.ndarray, intensity_type: str) -> dict: - """Computes Intensity-based statistical features. - These features refer to "Intensity-based statistical features" (ID = UHIW) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution). - intensity_type (str): Type of intensity to compute. Can be "arbitrary", "definite" or "filtered". - Will compute features only for "definite" intensity type. - - Return: - dict: Dictionnary containing all stats features. - - Raises: - ValueError: If `intensity_type` is not "arbitrary", "definite" or "filtered". - """ - assert intensity_type in ["arbitrary", "definite", "filtered"], \ - "intensity_type must be 'arbitrary', 'definite' or 'filtered'" - - x = vol[~np.isnan(vol[:])] # Initialization - - # Initialization of final structure (Dictionary) containing all features. - stats = {'Fstat_mean': [], - 'Fstat_var': [], - 'Fstat_skew': [], - 'Fstat_kurt': [], - 'Fstat_median': [], - 'Fstat_min': [], - 'Fstat_P10': [], - 'Fstat_P90': [], - 'Fstat_max': [], - 'Fstat_iqr': [], - 'Fstat_range': [], - 'Fstat_mad': [], - 'Fstat_rmad': [], - 'Fstat_medad': [], - 'Fstat_cov': [], - 'Fstat_qcod': [], - 'Fstat_energy': [], - 'Fstat_rms': [] - } - - # STARTING COMPUTATION - if intensity_type == "definite": - stats['Fstat_mean'] = np.mean(x) # Mean - stats['Fstat_var'] = np.var(x) # Variance - stats['Fstat_skew'] = skew(x) # Skewness - stats['Fstat_kurt'] = kurtosis(x) # Kurtosis - stats['Fstat_median'] = np.median(x) # Median - stats['Fstat_min'] = np.min(x) # Minimum grey level - stats['Fstat_P10'] = scoreatpercentile(x, 10) # 10th percentile - stats['Fstat_P90'] = scoreatpercentile(x, 90) # 90th percentile - stats['Fstat_max'] = np.max(x) # Maximum grey level - stats['Fstat_iqr'] = iqr(x) # Interquantile range - stats['Fstat_range'] = np.ptp(x) # Range max(x) - min(x) - stats['Fstat_mad'] = np.mean(np.absolute(x - np.mean(x))) # Mean absolute deviation - x_10_90 = x[np.where((x >= stats['Fstat_P10']) & - (x <= stats['Fstat_P90']), True, False)] - stats['Fstat_rmad'] = np.mean(np.abs(x_10_90 - np.mean(x_10_90))) # Robust mean absolute deviation - stats['Fstat_medad'] = np.mean(np.absolute(x - np.median(x))) # Median absolute deviation - stats['Fstat_cov'] = variation(x) # Coefficient of variation - x_75_25 = scoreatpercentile(x, 75) + scoreatpercentile(x, 25) - stats['Fstat_qcod'] = iqr(x)/x_75_25 # Quartile coefficient of dispersion - stats['Fstat_energy'] = np.sum(np.power(x, 2)) # Energy - stats['Fstat_rms'] = np.sqrt(np.mean(np.power(x, 2))) # Root mean square - - return stats - -def mean(vol: np.ndarray) -> float: - """Computes statistical mean feature of the input dataset (3D Array). - This feature refers to "Fstat_mean" (ID = Q4LE) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: Statistical mean feature - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return np.mean(x) # Mean - -def var(vol: np.ndarray) -> float: - """Computes statistical variance feature of the input dataset (3D Array). - This feature refers to "Fstat_var" (ID = ECT3) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: Statistical variance feature - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return np.var(x) # Variance - -def skewness(vol: np.ndarray) -> float: - """Computes the sample skewness feature of the input dataset (3D Array). - This feature refers to "Fstat_skew" (ID = KE2A) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: The skewness feature of values along an axis. Returning 0 where all values are - equal. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return skew(x) # Skewness - -def kurt(vol: np.ndarray) -> float: - """Computes the kurtosis (Fisher or Pearson) feature of the input dataset (3D Array). - This feature refers to "Fstat_kurt" (ID = IPH6) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: The kurtosis feature of values along an axis. If all values are equal, - return -3 for Fisher's definition and 0 for Pearson's definition. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return kurtosis(x) # Kurtosis - -def median(vol: np.ndarray) -> float: - """Computes the median feature along the specified axis of the input dataset (3D Array). - This feature refers to "Fstat_median" (ID = Y12H) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: The median feature of the array elements. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return np.median(x) # Median - -def min(vol: np.ndarray) -> float: - """Computes the minimum grey level feature of the input dataset (3D Array). - This feature refers to "Fstat_min" (ID = 1GSF) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: The minimum grey level feature of the array elements. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return np.min(x) # Minimum grey level - -def p10(vol: np.ndarray) -> float: - """Computes the score at the 10th percentile feature of the input dataset (3D Array). - This feature refers to "Fstat_P10" (ID = QG58) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: Score at 10th percentil. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return scoreatpercentile(x, 10) # 10th percentile - -def p90(vol: np.ndarray) -> float: - """Computes the score at the 90th percentile feature of the input dataset (3D Array). - This feature refers to "Fstat_P90" (ID = 8DWT) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: Score at 90th percentil. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return scoreatpercentile(x, 90) # 90th percentile - -def max(vol: np.ndarray) -> float: - """Computes the maximum grey level feature of the input dataset (3D Array). - This feature refers to "Fstat_max" (ID = 84IY) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: The maximum grey level feature of the array elements. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return np.max(x) # Maximum grey level - -def iqrange(vol: np.ndarray) -> float: - """Computes the interquartile range feature of the input dataset (3D Array). - This feature refers to "Fstat_iqr" (ID = SALO) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: Interquartile range. If axis != None, the output data-type is the same as that of the input. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return iqr(x) # Interquartile range - -def range(vol: np.ndarray) -> float: - """Range of values (maximum - minimum) feature along an axis of the input dataset (3D Array). - This feature refers to "Fstat_range" (ID = 2OJQ) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: A new array holding the range of values, unless out was specified, - in which case a reference to out is returned. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return np.ptp(x) # Range max(x) - min(x) - -def mad(vol: np.ndarray) -> float: - """Mean absolute deviation feature of the input dataset (3D Array). - This feature refers to "Fstat_mad" (ID = 4FUA) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float : A new array holding mean absolute deviation feature. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return np.mean(np.absolute(x - np.mean(x))) # Mean absolute deviation - -def rmad(vol: np.ndarray) -> float: - """Robust mean absolute deviation feature of the input dataset (3D Array). - This feature refers to "Fstat_rmad" (ID = 1128) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - P10(ndarray): Score at 10th percentil. - P90(ndarray): Score at 90th percentil. - - Returns: - float: A new array holding the robust mean absolute deviation. - """ - x = vol[~np.isnan(vol[:])] # Initialization - P10 = scoreatpercentile(x, 10) # 10th percentile - P90 = scoreatpercentile(x, 90) # 90th percentile - x_10_90 = x[np.where((x >= P10) & - (x <= P90), True, False)] # Holding x for (x >= P10) and (x<= P90) - - return np.mean(np.abs(x_10_90 - np.mean(x_10_90))) # Robust mean absolute deviation - -def medad(vol: np.ndarray) -> float: - """Median absolute deviation feature of the input dataset (3D Array). - This feature refers to "Fstat_medad" (ID = N72L) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: A new array holding the median absolute deviation feature. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return np.mean(np.absolute(x - np.median(x))) # Median absolute deviation - -def cov(vol: np.ndarray) -> float: - """Computes the coefficient of variation feature of the input dataset (3D Array). - This feature refers to "Fstat_cov" (ID = 7TET) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: A new array holding the coefficient of variation feature. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return variation(x) # Coefficient of variation - -def qcod(vol: np.ndarray) -> float: - """Computes the quartile coefficient of dispersion feature of the input dataset (3D Array). - This feature refers to "Fstat_qcod" (ID = 9S40) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: A new array holding the quartile coefficient of dispersion feature. - """ - x = vol[~np.isnan(vol[:])] # Initialization - x_75_25 = scoreatpercentile(x, 75) + scoreatpercentile(x, 25) - - return iqr(x) / x_75_25 # Quartile coefficient of dispersion - -def energy(vol: np.ndarray) -> float: - """Computes the energy feature of the input dataset (3D Array). - This feature refers to "Fstat_energy" (ID = N8CA) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: A new array holding the energy feature. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return np.sum(np.power(x, 2)) # Energy - -def rms(vol: np.ndarray) -> float: - """Computes the root mean square feature of the input dataset (3D Array). - This feature refers to "Fstat_rms" (ID = 5ZWQ) in - the `IBSI1 reference manual `_. - - Args: - vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest - (continuous imaging intensity distribution) - - Returns: - float: A new array holding the root mean square feature. - """ - x = vol[~np.isnan(vol[:])] # Initialization - - return np.sqrt(np.mean(np.power(x, 2))) # Root mean square +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import numpy as np +from scipy.stats import iqr, kurtosis, skew, scoreatpercentile, variation + + +def extract_all(vol: np.ndarray, intensity_type: str) -> dict: + """Computes Intensity-based statistical features. + These features refer to "Intensity-based statistical features" (ID = UHIW) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution). + intensity_type (str): Type of intensity to compute. Can be "arbitrary", "definite" or "filtered". + Will compute features only for "definite" intensity type. + + Return: + dict: Dictionnary containing all stats features. + + Raises: + ValueError: If `intensity_type` is not "arbitrary", "definite" or "filtered". + """ + assert intensity_type in ["arbitrary", "definite", "filtered"], \ + "intensity_type must be 'arbitrary', 'definite' or 'filtered'" + + x = vol[~np.isnan(vol[:])] # Initialization + + # Initialization of final structure (Dictionary) containing all features. + stats = {'Fstat_mean': [], + 'Fstat_var': [], + 'Fstat_skew': [], + 'Fstat_kurt': [], + 'Fstat_median': [], + 'Fstat_min': [], + 'Fstat_P10': [], + 'Fstat_P90': [], + 'Fstat_max': [], + 'Fstat_iqr': [], + 'Fstat_range': [], + 'Fstat_mad': [], + 'Fstat_rmad': [], + 'Fstat_medad': [], + 'Fstat_cov': [], + 'Fstat_qcod': [], + 'Fstat_energy': [], + 'Fstat_rms': [] + } + + # STARTING COMPUTATION + if intensity_type == "definite": + stats['Fstat_mean'] = np.mean(x) # Mean + stats['Fstat_var'] = np.var(x) # Variance + stats['Fstat_skew'] = skew(x) # Skewness + stats['Fstat_kurt'] = kurtosis(x) # Kurtosis + stats['Fstat_median'] = np.median(x) # Median + stats['Fstat_min'] = np.min(x) # Minimum grey level + stats['Fstat_P10'] = scoreatpercentile(x, 10) # 10th percentile + stats['Fstat_P90'] = scoreatpercentile(x, 90) # 90th percentile + stats['Fstat_max'] = np.max(x) # Maximum grey level + stats['Fstat_iqr'] = iqr(x) # Interquantile range + stats['Fstat_range'] = np.ptp(x) # Range max(x) - min(x) + stats['Fstat_mad'] = np.mean(np.absolute(x - np.mean(x))) # Mean absolute deviation + x_10_90 = x[np.where((x >= stats['Fstat_P10']) & + (x <= stats['Fstat_P90']), True, False)] + stats['Fstat_rmad'] = np.mean(np.abs(x_10_90 - np.mean(x_10_90))) # Robust mean absolute deviation + stats['Fstat_medad'] = np.mean(np.absolute(x - np.median(x))) # Median absolute deviation + stats['Fstat_cov'] = variation(x) # Coefficient of variation + x_75_25 = scoreatpercentile(x, 75) + scoreatpercentile(x, 25) + stats['Fstat_qcod'] = iqr(x)/x_75_25 # Quartile coefficient of dispersion + stats['Fstat_energy'] = np.sum(np.power(x, 2)) # Energy + stats['Fstat_rms'] = np.sqrt(np.mean(np.power(x, 2))) # Root mean square + + return stats + +def mean(vol: np.ndarray) -> float: + """Computes statistical mean feature of the input dataset (3D Array). + This feature refers to "Fstat_mean" (ID = Q4LE) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: Statistical mean feature + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return np.mean(x) # Mean + +def var(vol: np.ndarray) -> float: + """Computes statistical variance feature of the input dataset (3D Array). + This feature refers to "Fstat_var" (ID = ECT3) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: Statistical variance feature + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return np.var(x) # Variance + +def skewness(vol: np.ndarray) -> float: + """Computes the sample skewness feature of the input dataset (3D Array). + This feature refers to "Fstat_skew" (ID = KE2A) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: The skewness feature of values along an axis. Returning 0 where all values are + equal. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return skew(x) # Skewness + +def kurt(vol: np.ndarray) -> float: + """Computes the kurtosis (Fisher or Pearson) feature of the input dataset (3D Array). + This feature refers to "Fstat_kurt" (ID = IPH6) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: The kurtosis feature of values along an axis. If all values are equal, + return -3 for Fisher's definition and 0 for Pearson's definition. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return kurtosis(x) # Kurtosis + +def median(vol: np.ndarray) -> float: + """Computes the median feature along the specified axis of the input dataset (3D Array). + This feature refers to "Fstat_median" (ID = Y12H) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: The median feature of the array elements. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return np.median(x) # Median + +def min(vol: np.ndarray) -> float: + """Computes the minimum grey level feature of the input dataset (3D Array). + This feature refers to "Fstat_min" (ID = 1GSF) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: The minimum grey level feature of the array elements. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return np.min(x) # Minimum grey level + +def p10(vol: np.ndarray) -> float: + """Computes the score at the 10th percentile feature of the input dataset (3D Array). + This feature refers to "Fstat_P10" (ID = QG58) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: Score at 10th percentil. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return scoreatpercentile(x, 10) # 10th percentile + +def p90(vol: np.ndarray) -> float: + """Computes the score at the 90th percentile feature of the input dataset (3D Array). + This feature refers to "Fstat_P90" (ID = 8DWT) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: Score at 90th percentil. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return scoreatpercentile(x, 90) # 90th percentile + +def max(vol: np.ndarray) -> float: + """Computes the maximum grey level feature of the input dataset (3D Array). + This feature refers to "Fstat_max" (ID = 84IY) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: The maximum grey level feature of the array elements. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return np.max(x) # Maximum grey level + +def iqrange(vol: np.ndarray) -> float: + """Computes the interquartile range feature of the input dataset (3D Array). + This feature refers to "Fstat_iqr" (ID = SALO) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: Interquartile range. If axis != None, the output data-type is the same as that of the input. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return iqr(x) # Interquartile range + +def range(vol: np.ndarray) -> float: + """Range of values (maximum - minimum) feature along an axis of the input dataset (3D Array). + This feature refers to "Fstat_range" (ID = 2OJQ) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: A new array holding the range of values, unless out was specified, + in which case a reference to out is returned. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return np.ptp(x) # Range max(x) - min(x) + +def mad(vol: np.ndarray) -> float: + """Mean absolute deviation feature of the input dataset (3D Array). + This feature refers to "Fstat_mad" (ID = 4FUA) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float : A new array holding mean absolute deviation feature. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return np.mean(np.absolute(x - np.mean(x))) # Mean absolute deviation + +def rmad(vol: np.ndarray) -> float: + """Robust mean absolute deviation feature of the input dataset (3D Array). + This feature refers to "Fstat_rmad" (ID = 1128) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + P10(ndarray): Score at 10th percentil. + P90(ndarray): Score at 90th percentil. + + Returns: + float: A new array holding the robust mean absolute deviation. + """ + x = vol[~np.isnan(vol[:])] # Initialization + P10 = scoreatpercentile(x, 10) # 10th percentile + P90 = scoreatpercentile(x, 90) # 90th percentile + x_10_90 = x[np.where((x >= P10) & + (x <= P90), True, False)] # Holding x for (x >= P10) and (x<= P90) + + return np.mean(np.abs(x_10_90 - np.mean(x_10_90))) # Robust mean absolute deviation + +def medad(vol: np.ndarray) -> float: + """Median absolute deviation feature of the input dataset (3D Array). + This feature refers to "Fstat_medad" (ID = N72L) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: A new array holding the median absolute deviation feature. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return np.mean(np.absolute(x - np.median(x))) # Median absolute deviation + +def cov(vol: np.ndarray) -> float: + """Computes the coefficient of variation feature of the input dataset (3D Array). + This feature refers to "Fstat_cov" (ID = 7TET) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: A new array holding the coefficient of variation feature. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return variation(x) # Coefficient of variation + +def qcod(vol: np.ndarray) -> float: + """Computes the quartile coefficient of dispersion feature of the input dataset (3D Array). + This feature refers to "Fstat_qcod" (ID = 9S40) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: A new array holding the quartile coefficient of dispersion feature. + """ + x = vol[~np.isnan(vol[:])] # Initialization + x_75_25 = scoreatpercentile(x, 75) + scoreatpercentile(x, 25) + + return iqr(x) / x_75_25 # Quartile coefficient of dispersion + +def energy(vol: np.ndarray) -> float: + """Computes the energy feature of the input dataset (3D Array). + This feature refers to "Fstat_energy" (ID = N8CA) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: A new array holding the energy feature. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return np.sum(np.power(x, 2)) # Energy + +def rms(vol: np.ndarray) -> float: + """Computes the root mean square feature of the input dataset (3D Array). + This feature refers to "Fstat_rms" (ID = 5ZWQ) in + the `IBSI1 reference manual `_. + + Args: + vol(ndarray): 3D volume, NON-QUANTIZED, with NaNs outside the region of interest + (continuous imaging intensity distribution) + + Returns: + float: A new array holding the root mean square feature. + """ + x = vol[~np.isnan(vol[:])] # Initialization + + return np.sqrt(np.mean(np.power(x, 2))) # Root mean square diff --git a/MEDimage/biomarkers/utils.py b/MEDiml/biomarkers/utils.py similarity index 100% rename from MEDimage/biomarkers/utils.py rename to MEDiml/biomarkers/utils.py diff --git a/MEDimage/filters/TexturalFilter.py b/MEDiml/filters/TexturalFilter.py similarity index 100% rename from MEDimage/filters/TexturalFilter.py rename to MEDiml/filters/TexturalFilter.py diff --git a/MEDimage/filters/__init__.py b/MEDiml/filters/__init__.py similarity index 100% rename from MEDimage/filters/__init__.py rename to MEDiml/filters/__init__.py diff --git a/MEDimage/filters/apply_filter.py b/MEDiml/filters/apply_filter.py similarity index 100% rename from MEDimage/filters/apply_filter.py rename to MEDiml/filters/apply_filter.py diff --git a/MEDimage/filters/gabor.py b/MEDiml/filters/gabor.py similarity index 100% rename from MEDimage/filters/gabor.py rename to MEDiml/filters/gabor.py diff --git a/MEDimage/filters/laws.py b/MEDiml/filters/laws.py similarity index 100% rename from MEDimage/filters/laws.py rename to MEDiml/filters/laws.py diff --git a/MEDimage/filters/log.py b/MEDiml/filters/log.py similarity index 100% rename from MEDimage/filters/log.py rename to MEDiml/filters/log.py diff --git a/MEDimage/filters/mean.py b/MEDiml/filters/mean.py similarity index 100% rename from MEDimage/filters/mean.py rename to MEDiml/filters/mean.py diff --git a/MEDimage/filters/textural_filters_kernels.py b/MEDiml/filters/textural_filters_kernels.py similarity index 100% rename from MEDimage/filters/textural_filters_kernels.py rename to MEDiml/filters/textural_filters_kernels.py diff --git a/MEDimage/filters/utils.py b/MEDiml/filters/utils.py similarity index 100% rename from MEDimage/filters/utils.py rename to MEDiml/filters/utils.py diff --git a/MEDimage/filters/wavelet.py b/MEDiml/filters/wavelet.py similarity index 100% rename from MEDimage/filters/wavelet.py rename to MEDiml/filters/wavelet.py diff --git a/MEDimage/learning/DataCleaner.py b/MEDiml/learning/DataCleaner.py similarity index 100% rename from MEDimage/learning/DataCleaner.py rename to MEDiml/learning/DataCleaner.py diff --git a/MEDimage/learning/DesignExperiment.py b/MEDiml/learning/DesignExperiment.py similarity index 100% rename from MEDimage/learning/DesignExperiment.py rename to MEDiml/learning/DesignExperiment.py diff --git a/MEDimage/learning/FSR.py b/MEDiml/learning/FSR.py similarity index 99% rename from MEDimage/learning/FSR.py rename to MEDiml/learning/FSR.py index c30deb9..a3631d8 100644 --- a/MEDimage/learning/FSR.py +++ b/MEDiml/learning/FSR.py @@ -5,11 +5,11 @@ import pandas as pd from numpyencoder import NumpyEncoder -from MEDimage.learning.ml_utils import (combine_rad_tables, finalize_rad_table, +from MEDiml.learning.ml_utils import (combine_rad_tables, finalize_rad_table, get_stratified_splits, intersect_var_tables) -from MEDimage.utils.get_full_rad_names import get_full_rad_names -from MEDimage.utils.json_utils import save_json +from MEDiml.utils.get_full_rad_names import get_full_rad_names +from MEDiml.utils.json_utils import save_json class FSR: diff --git a/MEDimage/learning/Normalization.py b/MEDiml/learning/Normalization.py similarity index 100% rename from MEDimage/learning/Normalization.py rename to MEDiml/learning/Normalization.py diff --git a/MEDimage/learning/RadiomicsLearner.py b/MEDiml/learning/RadiomicsLearner.py similarity index 98% rename from MEDimage/learning/RadiomicsLearner.py rename to MEDiml/learning/RadiomicsLearner.py index b112a4d..a731e57 100644 --- a/MEDimage/learning/RadiomicsLearner.py +++ b/MEDiml/learning/RadiomicsLearner.py @@ -13,16 +13,16 @@ from sklearn.model_selection import GridSearchCV, RandomizedSearchCV from xgboost import XGBClassifier -from MEDimage.learning.DataCleaner import DataCleaner -from MEDimage.learning.DesignExperiment import DesignExperiment -from MEDimage.learning.FSR import FSR -from MEDimage.learning.ml_utils import (average_results, combine_rad_tables, +from MEDiml.learning.DataCleaner import DataCleaner +from MEDiml.learning.DesignExperiment import DesignExperiment +from MEDiml.learning.FSR import FSR +from MEDiml.learning.ml_utils import (average_results, combine_rad_tables, feature_imporance_analysis, finalize_rad_table, get_ml_test_table, get_radiomics_table, intersect, intersect_var_tables, save_model) -from MEDimage.learning.Normalization import Normalization -from MEDimage.learning.Results import Results +from MEDiml.learning.Normalization import Normalization +from MEDiml.learning.Results import Results from ..utils.json_utils import load_json, save_json diff --git a/MEDimage/learning/Results.py b/MEDiml/learning/Results.py similarity index 99% rename from MEDimage/learning/Results.py rename to MEDiml/learning/Results.py index 2c69654..839b728 100644 --- a/MEDimage/learning/Results.py +++ b/MEDiml/learning/Results.py @@ -17,10 +17,10 @@ from numpyencoder import NumpyEncoder from sklearn import metrics -from MEDimage.learning.ml_utils import feature_imporance_analysis, list_metrics -from MEDimage.learning.Stats import Stats -from MEDimage.utils.json_utils import load_json, save_json -from MEDimage.utils.texture_features_names import * +from MEDiml.learning.ml_utils import feature_imporance_analysis, list_metrics +from MEDiml.learning.Stats import Stats +from MEDiml.utils.json_utils import load_json, save_json +from MEDiml.utils.texture_features_names import * class Results: diff --git a/MEDimage/learning/Stats.py b/MEDiml/learning/Stats.py similarity index 99% rename from MEDimage/learning/Stats.py rename to MEDiml/learning/Stats.py index 8af2a54..5d5be3f 100644 --- a/MEDimage/learning/Stats.py +++ b/MEDiml/learning/Stats.py @@ -10,7 +10,7 @@ import scipy from sklearn import metrics -from MEDimage.utils.json_utils import load_json +from MEDiml.utils.json_utils import load_json class Stats: diff --git a/MEDimage/learning/__init__.py b/MEDiml/learning/__init__.py similarity index 100% rename from MEDimage/learning/__init__.py rename to MEDiml/learning/__init__.py diff --git a/MEDimage/learning/cleaning_utils.py b/MEDiml/learning/cleaning_utils.py similarity index 100% rename from MEDimage/learning/cleaning_utils.py rename to MEDiml/learning/cleaning_utils.py diff --git a/MEDimage/learning/ml_utils.py b/MEDiml/learning/ml_utils.py similarity index 99% rename from MEDimage/learning/ml_utils.py rename to MEDiml/learning/ml_utils.py index edaa744..cca73e0 100644 --- a/MEDimage/learning/ml_utils.py +++ b/MEDiml/learning/ml_utils.py @@ -16,9 +16,9 @@ from numpyencoder import NumpyEncoder from sklearn.model_selection import StratifiedKFold -from MEDimage.utils import get_institutions_from_ids -from MEDimage.utils.get_full_rad_names import get_full_rad_names -from MEDimage.utils.json_utils import load_json, save_json +from MEDiml.utils import get_institutions_from_ids +from MEDiml.utils.get_full_rad_names import get_full_rad_names +from MEDiml.utils.json_utils import load_json, save_json # Define useful constants diff --git a/MEDimage/processing/__init__.py b/MEDiml/processing/__init__.py similarity index 100% rename from MEDimage/processing/__init__.py rename to MEDiml/processing/__init__.py diff --git a/MEDimage/processing/compute_suv_map.py b/MEDiml/processing/compute_suv_map.py similarity index 100% rename from MEDimage/processing/compute_suv_map.py rename to MEDiml/processing/compute_suv_map.py diff --git a/MEDimage/processing/discretisation.py b/MEDiml/processing/discretisation.py similarity index 99% rename from MEDimage/processing/discretisation.py rename to MEDiml/processing/discretisation.py index 12376b9..66a0f02 100644 --- a/MEDimage/processing/discretisation.py +++ b/MEDiml/processing/discretisation.py @@ -111,7 +111,7 @@ def discretize(vol_re: np.ndarray, # DISCRETISATION if discr_type in ["FBS", "FBSequal"]: - if user_set_min_val is not None: + if user_set_min_val: min_val = deepcopy(user_set_min_val) else: min_val = np.nanmin(vol_quant_re) diff --git a/MEDimage/processing/interpolation.py b/MEDiml/processing/interpolation.py similarity index 100% rename from MEDimage/processing/interpolation.py rename to MEDiml/processing/interpolation.py diff --git a/MEDimage/processing/resegmentation.py b/MEDiml/processing/resegmentation.py similarity index 100% rename from MEDimage/processing/resegmentation.py rename to MEDiml/processing/resegmentation.py diff --git a/MEDimage/processing/segmentation.py b/MEDiml/processing/segmentation.py similarity index 100% rename from MEDimage/processing/segmentation.py rename to MEDiml/processing/segmentation.py diff --git a/MEDimage/utils/__init__.py b/MEDiml/utils/__init__.py similarity index 100% rename from MEDimage/utils/__init__.py rename to MEDiml/utils/__init__.py diff --git a/MEDimage/utils/batch_patients.py b/MEDiml/utils/batch_patients.py similarity index 100% rename from MEDimage/utils/batch_patients.py rename to MEDiml/utils/batch_patients.py diff --git a/MEDimage/utils/create_radiomics_table.py b/MEDiml/utils/create_radiomics_table.py similarity index 100% rename from MEDimage/utils/create_radiomics_table.py rename to MEDiml/utils/create_radiomics_table.py diff --git a/MEDimage/utils/data_frame_export.py b/MEDiml/utils/data_frame_export.py similarity index 100% rename from MEDimage/utils/data_frame_export.py rename to MEDiml/utils/data_frame_export.py diff --git a/MEDimage/utils/find_process_names.py b/MEDiml/utils/find_process_names.py similarity index 100% rename from MEDimage/utils/find_process_names.py rename to MEDiml/utils/find_process_names.py diff --git a/MEDimage/utils/get_file_paths.py b/MEDiml/utils/get_file_paths.py similarity index 100% rename from MEDimage/utils/get_file_paths.py rename to MEDiml/utils/get_file_paths.py diff --git a/MEDimage/utils/get_full_rad_names.py b/MEDiml/utils/get_full_rad_names.py similarity index 100% rename from MEDimage/utils/get_full_rad_names.py rename to MEDiml/utils/get_full_rad_names.py diff --git a/MEDimage/utils/get_institutions_from_ids.py b/MEDiml/utils/get_institutions_from_ids.py similarity index 100% rename from MEDimage/utils/get_institutions_from_ids.py rename to MEDiml/utils/get_institutions_from_ids.py diff --git a/MEDimage/utils/get_patient_id_from_scan_name.py b/MEDiml/utils/get_patient_id_from_scan_name.py similarity index 100% rename from MEDimage/utils/get_patient_id_from_scan_name.py rename to MEDiml/utils/get_patient_id_from_scan_name.py diff --git a/MEDimage/utils/get_patient_names.py b/MEDiml/utils/get_patient_names.py similarity index 100% rename from MEDimage/utils/get_patient_names.py rename to MEDiml/utils/get_patient_names.py diff --git a/MEDimage/utils/get_radiomic_names.py b/MEDiml/utils/get_radiomic_names.py similarity index 100% rename from MEDimage/utils/get_radiomic_names.py rename to MEDiml/utils/get_radiomic_names.py diff --git a/MEDimage/utils/get_scan_name_from_rad_name.py b/MEDiml/utils/get_scan_name_from_rad_name.py similarity index 100% rename from MEDimage/utils/get_scan_name_from_rad_name.py rename to MEDiml/utils/get_scan_name_from_rad_name.py diff --git a/MEDimage/utils/image_reader_SITK.py b/MEDiml/utils/image_reader_SITK.py similarity index 100% rename from MEDimage/utils/image_reader_SITK.py rename to MEDiml/utils/image_reader_SITK.py diff --git a/MEDimage/utils/image_volume_obj.py b/MEDiml/utils/image_volume_obj.py similarity index 100% rename from MEDimage/utils/image_volume_obj.py rename to MEDiml/utils/image_volume_obj.py diff --git a/MEDimage/utils/imref.py b/MEDiml/utils/imref.py similarity index 100% rename from MEDimage/utils/imref.py rename to MEDiml/utils/imref.py diff --git a/MEDimage/utils/initialize_features_names.py b/MEDiml/utils/initialize_features_names.py similarity index 100% rename from MEDimage/utils/initialize_features_names.py rename to MEDiml/utils/initialize_features_names.py diff --git a/MEDimage/utils/inpolygon.py b/MEDiml/utils/inpolygon.py similarity index 100% rename from MEDimage/utils/inpolygon.py rename to MEDiml/utils/inpolygon.py diff --git a/MEDimage/utils/interp3.py b/MEDiml/utils/interp3.py similarity index 100% rename from MEDimage/utils/interp3.py rename to MEDiml/utils/interp3.py diff --git a/MEDimage/utils/json_utils.py b/MEDiml/utils/json_utils.py similarity index 100% rename from MEDimage/utils/json_utils.py rename to MEDiml/utils/json_utils.py diff --git a/MEDimage/utils/mode.py b/MEDiml/utils/mode.py similarity index 100% rename from MEDimage/utils/mode.py rename to MEDiml/utils/mode.py diff --git a/MEDimage/utils/parse_contour_string.py b/MEDiml/utils/parse_contour_string.py similarity index 100% rename from MEDimage/utils/parse_contour_string.py rename to MEDiml/utils/parse_contour_string.py diff --git a/MEDimage/utils/save_MEDscan.py b/MEDiml/utils/save_MEDscan.py similarity index 100% rename from MEDimage/utils/save_MEDscan.py rename to MEDiml/utils/save_MEDscan.py diff --git a/MEDimage/utils/strfind.py b/MEDiml/utils/strfind.py similarity index 100% rename from MEDimage/utils/strfind.py rename to MEDiml/utils/strfind.py diff --git a/MEDimage/utils/textureTools.py b/MEDiml/utils/textureTools.py similarity index 100% rename from MEDimage/utils/textureTools.py rename to MEDiml/utils/textureTools.py diff --git a/MEDimage/utils/texture_features_names.py b/MEDiml/utils/texture_features_names.py similarity index 100% rename from MEDimage/utils/texture_features_names.py rename to MEDiml/utils/texture_features_names.py diff --git a/MEDimage/utils/write_radiomics_csv.py b/MEDiml/utils/write_radiomics_csv.py similarity index 100% rename from MEDimage/utils/write_radiomics_csv.py rename to MEDiml/utils/write_radiomics_csv.py diff --git a/MEDimage/wrangling/DataManager.py b/MEDiml/wrangling/DataManager.py similarity index 99% rename from MEDimage/wrangling/DataManager.py rename to MEDiml/wrangling/DataManager.py index 6105012..b6fcfb3 100644 --- a/MEDimage/wrangling/DataManager.py +++ b/MEDiml/wrangling/DataManager.py @@ -341,7 +341,7 @@ def process_all_dicoms(self) -> Union[List[MEDscan], None]: self.summary[name_save.split('-')[0]][name_save.split('-')[1]][scan_type].append(name_save) else: if self.save: - logging.warning(f"The patient ID of the following file: {name_save} does not respect the MEDimage "\ + logging.warning(f"The patient ID of the following file: {name_save} does not respect the MEDiml "\ "naming convention 'study-institution-id' (Ex: Glioma-TCGA-001)") nb_job_left = n_scans - n_batch @@ -382,7 +382,7 @@ def process_all_dicoms(self) -> Union[List[MEDscan], None]: self.summary[name_save.split('-')[0]][name_save.split('-')[1]][scan_type].append(name_save) else: if self.save: - logging.warning(f"The patient ID of the following file: {name_save} does not respect the MEDimage "\ + logging.warning(f"The patient ID of the following file: {name_save} does not respect the MEDiml "\ "naming convention 'study-institution-id' (Ex: Glioma-TCGA-001)") print('DONE') @@ -618,7 +618,7 @@ def process_all_niftis(self) -> List[MEDscan]: self.summary[name_save.split('-')[0]][name_save.split('-')[1]][scan_type].append(name_save) else: if self.save: - logging.warning(f"The patient ID of the following file: {name_save} does not respect the MEDimage "\ + logging.warning(f"The patient ID of the following file: {name_save} does not respect the MEDiml "\ "naming convention 'study-institution-id' (Ex: Glioma-TCGA-001)") print('DONE') diff --git a/MEDimage/wrangling/ProcessDICOM.py b/MEDiml/wrangling/ProcessDICOM.py similarity index 100% rename from MEDimage/wrangling/ProcessDICOM.py rename to MEDiml/wrangling/ProcessDICOM.py diff --git a/MEDimage/wrangling/__init__.py b/MEDiml/wrangling/__init__.py similarity index 100% rename from MEDimage/wrangling/__init__.py rename to MEDiml/wrangling/__init__.py diff --git a/Makefile.mk b/Makefile.mk index 803d5c5..19e2f59 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -2,7 +2,7 @@ # Configuration variables # -WORKDIR?=./MEDimage +WORKDIR?=./MEDiml REQUIREMENTS_TXT?=environment.yml SETUP_PY?=setup.py python_version := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) @@ -14,7 +14,7 @@ python_version := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) .PHONY: create_environment create_environment: conda update --yes --name base --channel defaults conda - conda env create --name medimage --file environment.yml + conda env create --name mediml --file environment.yml .PHONY: clean clean: diff --git a/README.md b/README.md index 74e5d25..afca02c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@
- + [![PyPI - Python Version](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10-blue)](https://www.python.org/downloads/release/python-380/) [![PyPI - version](https://img.shields.io/badge/pypi-v0.9.8-blue)](https://pypi.org/project/medimage-pkg/) -[![Continuous Integration](https://github.com/MahdiAll99/MEDimage/actions/workflows/python-app.yml/badge.svg)](https://github.com/MahdiAll99/MEDimage/actions/workflows/python-app.yml) +[![Continuous Integration](https://github.com/MEDomicsLab/MEDiml/actions/workflows/python-app.yml/badge.svg)](https://github.com/MEDomicsLab/MEDiml/actions/workflows/python-app.yml) [![Documentation Status](https://readthedocs.org/projects/medimage/badge/?version=latest)](https://medimage.readthedocs.io/en/latest/?badge=latest) [![License: GPL-3](https://img.shields.io/badge/license-GPLv3-blue)](LICENSE) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MahdiAll99/MEDimage/blob/main/notebooks/tutorial/DataManager-Tutorial.ipynb) @@ -25,26 +25,26 @@ * [9. Statement](#9-statement) ## 1. Introduction -MEDimage is an open-source Python package that can be used for processing multi-modal medical images (MRI, CT or PET) and for extracting their radiomic features. This package is meant to facilitate the processing of medical images and the subsequent computation of all types of radiomic features while maintaining the reproducibility of analyses. This package has been standardized with the [IBSI](https://theibsi.github.io/) norms. +MEDiml is an open-source Python package that can be used for processing multi-modal medical images (MRI, CT or PET) and for extracting their radiomic features. This package is meant to facilitate the processing of medical images and the subsequent computation of all types of radiomic features while maintaining the reproducibility of analyses. This package has been standardized with the [IBSI](https://theibsi.github.io/) norms. -![MEDimage overview](https://raw.githubusercontent.com/MahdiAll99/MEDimage/main/docs/figures/pakcage-overview.png) +![MEDiml overview](https://raw.githubusercontent.com/MahdiAll99/MEDimage/main/docs/figures/pakcage-overview.png) ## 2. Installation ### Python installation -The MEDimage package requires *Python 3.8* or more. If you don't have it installed on your machine, follow the instructions [here](https://github.com/MahdiAll99/MEDimage/blob/main/python.md) to install it. +The MEDiml package requires *Python 3.8* or more. If you don't have it installed on your machine, follow the instructions [here](https://github.com/MEDomicsLab/MEDiml/blob/main/python.md) to install it. ### Package installation -You can easily install the ``MEDimage`` package from PyPI using: +You can easily install the ``MEDiml`` package from PyPI using: ``` -pip install medimage-pkg +pip install MEDiml ``` For more installation options (Conda, Poetry...) check out the [installation documentation](https://medimage.readthedocs.io/en/latest/Installation.html). ## 3. Generating the documentation locally -The [documentation](https://medimage.readthedocs.io/en/latest/) of the MEDimage package was created using Sphinx. However, you can generate and host it locally by compiling the documentation source code using : +The [documentation](https://medimage.readthedocs.io/en/latest/) of the MEDiml package was created using Sphinx. However, you can generate and host it locally by compiling the documentation source code using : ``` cd docs @@ -64,22 +64,22 @@ python -m http.server import os import pickle -import MEDimage +import MEDiml -# Load the DataManager -dm = MEDimage.DataManager(path_dicoms=os.getcwd()) +# Load MEDiml DataManager +dm = MEDiml.DataManager(path_dicoms=os.getcwd()) -# Process the DICOM files and retrieve the MEDimage object +# Process the DICOM files and retrieve the MEDiml object med_obj = dm.process_all_dicoms()[0] # Extract ROI mask from the object -vol_obj_init, roi_obj_init = MEDimage.processing.get_roi_from_indexes( +vol_obj_init, roi_obj_init = MEDiml.processing.get_roi_from_indexes( med_obj, name_roi='{ED}+{ET}+{NET}', box_string='full') # Extract features from the imaging data -local_intensity = MEDimage.biomarkers.local_intensity.extract_all( +local_intensity = MEDiml.biomarkers.local_intensity.extract_all( img_obj=vol_obj_init.data, roi_obj=roi_obj_init.data, res=[1, 1, 1] @@ -99,19 +99,19 @@ med_obj.save_radiomics( ## 5. Tutorials -We have created many [tutorial notebooks](https://github.com/MahdiAll99/MEDimage/tree/main/notebooks) to assist you in learning how to use the different parts of the package. More details can be found in the [documentation](https://medimage.readthedocs.io/en/latest/tutorials.html). +We have created many [tutorial notebooks](https://github.com/MEDomicsLab/MEDiml/tree/main/notebooks) to assist you in learning how to use the different parts of the package. More details can be found in the [documentation](https://medimage.readthedocs.io/en/latest/tutorials.html). ## 6. IBSI Standardization The image biomarker standardization initiative ([IBSI](https://theibsi.github.io)) is an independent international collaboration that aims to standardize the extraction of image biomarkers from acquired imaging. The IBSI therefore seeks to provide image biomarker nomenclature and definitions, benchmark datasets, and benchmark values to verify image processing and image biomarker calculations, as well as reporting guidelines, for high-throughput image analysis. We participate in this collaboration with our package to make sure it respects international nomenclatures and definitions. The participation was separated into two chapters: - ### IBSI Chapter 1 - [The IBSI chapter 1](https://theibsi.github.io/ibsi1/) is dedicated to the standardization of commonly used radiomic features. It was initiated in September 2016 and reached completion in March 2020. We have created two [jupyter notebooks](https://github.com/MahdiAll99/MEDimage/tree/main/notebooks/ibsi) for each phase of the chapter and made them available for the users to run the IBSI tests for themselves. The tests can also be explored in interactive Colab notebooks that are directly accessible here: + [The IBSI chapter 1](https://theibsi.github.io/ibsi1/) is dedicated to the standardization of commonly used radiomic features. It was initiated in September 2016 and reached completion in March 2020. We have created two [jupyter notebooks](https://github.com/MEDomicsLab/MEDiml/tree/main/notebooks/ibsi) for each phase of the chapter and made them available for the users to run the IBSI tests for themselves. The tests can also be explored in interactive Colab notebooks that are directly accessible here: - **Phase 1**: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MahdiAll99/MEDimage/blob/main/notebooks/ibsi/ibsi1p1.ipynb) - **Phase 2**: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MahdiAll99/MEDimage/blob/main/notebooks/ibsi/ibsi1p2.ipynb) - ### IBSI Chapter 2 - [The IBSI chapter 2](https://theibsi.github.io/ibsi2/) was launched in June 2020 and reached completion in February 2024. It is dedicated to the standardization of commonly used imaging filters in radiomic studies. We have created two [jupyter notebooks](https://github.com/MahdiAll99/MEDimage/tree/main/notebooks/ibsi) for each phase of the chapter and made them available for the users to run the IBSI tests for themselves and validate image filtering and image biomarker calculations from filter response maps. The tests can also be explored in interactive Colab notebooks that are directly accessible here: + [The IBSI chapter 2](https://theibsi.github.io/ibsi2/) was launched in June 2020 and reached completion in February 2024. It is dedicated to the standardization of commonly used imaging filters in radiomic studies. We have created two [jupyter notebooks](https://github.com/MEDomicsLab/MEDiml/tree/main/notebooks/ibsi) for each phase of the chapter and made them available for the users to run the IBSI tests for themselves and validate image filtering and image biomarker calculations from filter response maps. The tests can also be explored in interactive Colab notebooks that are directly accessible here: - **Phase 1**: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MahdiAll99/MEDimage/blob/main/notebooks/ibsi/ibsi2p1.ipynb) - **Phase 2**: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MahdiAll99/MEDimage/blob/main/notebooks/ibsi/ibsi2p2.ipynb) @@ -129,10 +129,10 @@ You can view and run the tests locally by installing the [Jupyter Notebook](http ``` python -m pip install jupyter ``` -Then add the installed `medimage` environment to the Jupyter Notebook kernels using: +Then add the installed `MEDiml` environment to the Jupyter Notebook kernels using: ``` -python -m ipykernel install --user --name=medimage +python -m ipykernel install --user --name=MEDiml ``` Then access the IBSI tests folder using: @@ -148,10 +148,10 @@ jupyter notebook ``` ## 7. Acknowledgement -MEDimage is an open-source package developed at the [MEDomics-Udes](https://www.medomics-udes.org/en/) laboratory with the collaboration of the international consortium [MEDomics](https://www.medomics.ai/). We welcome any contribution and feedback. Furthermore, we wish that this package could serve the growing radiomics research community by providing a flexible as well as [IBSI](https://theibsi.github.io/) standardized tool to reimplement existing methods and develop new ones. +MEDiml is an open-source package developed at the [MEDomicsLab](https://www.medomicslab.com/en/) laboratory with the collaboration of the international consortium [MEDomics](https://www.medomics.ai/). We welcome any contribution and feedback. Furthermore, we wish that this package could serve the growing radiomics research community by providing a flexible as well as [IBSI](https://theibsi.github.io/) standardized tool to reimplement existing methods and develop new ones. ## 8. Authors -* [MEDomics-Udes](https://www.medomics-udes.org/en/): Research laboratory at Université de Sherbrooke. +* [MEDomicsLab](https://www.medomicslab.com/en/): Research laboratory at Université de Sherbrooke & McGill University. * [MEDomics](https://github.com/medomics/): MEDomics consortium. ## 9. Statement @@ -176,4 +176,4 @@ Here's what the license entails: 9. The software author or license can not be held liable for any damages inflicted by the software. ``` -More information on about the [LICENSE can be found here](https://github.com/MEDomics-UdeS/MEDimage/blob/main/LICENSE.md) +More information on about the [LICENSE can be found here](https://github.com/MEDomicsLab/MEDiml/blob/main/LICENSE.md) diff --git a/docs/FAQs.rst b/docs/FAQs.rst index 21cd6d2..47e9044 100644 --- a/docs/FAQs.rst +++ b/docs/FAQs.rst @@ -1,4 +1,4 @@ FAQs ========================== -If your question is not here, feel free to ask it on `GitHub `__ \ No newline at end of file +If your question is not here, feel free to ask it on `GitHub `__ \ No newline at end of file diff --git a/docs/Installation.rst b/docs/Installation.rst index 468a447..bcff1b4 100644 --- a/docs/Installation.rst +++ b/docs/Installation.rst @@ -4,14 +4,13 @@ Installation Python installation ------------------- -The MEDimage package requires python 3.8 or more to be run. If you don't have it installed on your machine, follow \ -the instructions `here `__. +The MEDiml package requires python 3.8 or more to be run. If you don't have it installed on your machine, follow \ +the instructions `here `__. Install via pip --------------- -``MEDimage`` is available on PyPi for installation via ``pip`` which allows you to install the package in one step :: - - pip install medimage-pkg +``MEDiml`` is available on PyPi for installation via ``pip`` which allows you to install the package in one step :: + pip install mediml Install from source ------------------- @@ -28,23 +27,23 @@ following the instructions `here `__ tests require specific parameters for radiomics extraction for each test. You can check a full example of the file here: -`notebooks/ibsi/settings/ `__. - +`notebooks/ibsi/settings/ `__. This section will walk you through the details on how to set up and use the configuration file. It will be separated to four subdivision: - :ref:`Pre-checks` @@ -145,7 +144,7 @@ e.g. { "pre_radiomics_checks" : { - "path_data" : "home/user/medimage/data/npy/sts", + "path_data" : "home/user/mediml/data/npy/sts", } } @@ -164,7 +163,7 @@ e.g. { "pre_radiomics_checks" : { - "path_save_checks" : "home/user/medimage/checks", + "path_save_checks" : "home/user/mediml/checks", } } @@ -183,7 +182,7 @@ e.g. { "pre_radiomics_checks" : { - "path_csv" : "home/user/medimage/data/csv/roiNames_GTV.csv", + "path_csv" : "home/user/mediml/data/csv/roiNames_GTV.csv", } } @@ -335,7 +334,7 @@ e.g. "type": "List" }, "outliers": { - "description": "Outlier resegmentation algorithm. For now ``MEDimage`` only implements ``\"Collewet\"`` algorithms. + "description": "Outlier resegmentation algorithm. For now ``MEDiml`` only implements ``\"Collewet\"`` algorithms. Leave empty for no outlier resegmentation", "type": "string" } @@ -508,7 +507,7 @@ This parameter is only used for PET scans and is set as follows: } .. note:: - This parameter concern PET scans only. ``MEDimage`` only computes suv map for DICOM scans, since the computation relies on + This parameter concern PET scans only. ``MEDiml`` only computes suv map for DICOM scans, since the computation relies on DICOM headers for computation and assumes it's already computed for NIfTI scans. .. jsonschema:: @@ -828,7 +827,7 @@ Filtering parameters ^^^^^^^^^^^^^^^^^^^^ Filtering parameters are organized in a separate dictionary, each dictionary contains -parameters for every filter of the ``MEDimage``: +parameters for every filter of the ``MEDiml``: .. code-block:: JSON diff --git a/docs/figures/MEDimlLogo.png b/docs/figures/MEDimlLogo.png new file mode 100644 index 0000000..3cca182 Binary files /dev/null and b/docs/figures/MEDimlLogo.png differ diff --git a/docs/filters.rst b/docs/filters.rst index 1368283..bd547c0 100644 --- a/docs/filters.rst +++ b/docs/filters.rst @@ -4,7 +4,7 @@ Filters gabor -------------------------------------------- -.. automodule:: MEDimage.filters.gabor +.. automodule:: MEDiml.filters.gabor :members: :undoc-members: :show-inheritance: @@ -12,7 +12,7 @@ gabor laws ----------------------------------------- -.. automodule:: MEDimage.filters.laws +.. automodule:: MEDiml.filters.laws :members: :undoc-members: :show-inheritance: @@ -20,7 +20,7 @@ laws log ----------------------------------------- -.. automodule:: MEDimage.filters.log +.. automodule:: MEDiml.filters.log :members: :undoc-members: :show-inheritance: @@ -28,7 +28,7 @@ log mean ----------------------------------------- -.. automodule:: MEDimage.filters.mean +.. automodule:: MEDiml.filters.mean :members: :undoc-members: :show-inheritance: @@ -36,7 +36,7 @@ mean wavelet ----------------------------------------- -.. automodule:: MEDimage.filters.wavelet +.. automodule:: MEDiml.filters.wavelet :members: :undoc-members: :show-inheritance: @@ -44,7 +44,7 @@ wavelet apply\_filter ----------------------------------------- -.. automodule:: MEDimage.filters.apply_filter +.. automodule:: MEDiml.filters.apply_filter :members: :undoc-members: :show-inheritance: @@ -52,7 +52,7 @@ apply\_filter utils ----------------------------------------- -.. automodule:: MEDimage.filters.utils +.. automodule:: MEDiml.filters.utils :members: :undoc-members: :show-inheritance: diff --git a/docs/index.rst b/docs/index.rst index 7a46b93..37a7e1a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,17 +1,17 @@ -Welcome to the MEDimage documentation! +Welcome to the MEDiml documentation! ======================================= .. image:: /figures/pakcage-overview.png :width: 100% -``MEDimage`` is a comprehensive tool, for processing and extracting features from medical images. It also supports the training, evaluation, +``MEDiml`` is a comprehensive tool, for processing and extracting features from medical images. It also supports the training, evaluation, and optimality analysis, streamlining radiomics approaches. It complies with `international radiomic feature extraction standards \ `_ and `international standards for convolotuional filters \ `_ in the context of radiomics. -``MEDimage`` also uses an interactive, easy-to-install application (see image below) that grants users access to all software modules. Find more details `here \ -`_ +``MEDiml`` also uses an interactive, easy-to-install application (see image below) that grants users access to all software modules. Find more details `here \ +`_ .. carousel:: :show_controls: @@ -19,15 +19,15 @@ and optimality analysis, streamlining radiomics approaches. It complies with `in .. image:: /figures/InterfaceMEDimage.JPG :width: 500 - :target: https://medomics-udes.gitbook.io/medomicslab-docs/tutorials/radiomics/learning + :target: https://medomicslab.gitbook.io/mediml-app-docs/learning .. image:: /figures/MEDimage-app-be.png :width: 500 - :target: https://medomics-udes.gitbook.io/medomicslab-docs/tutorials/radiomics/feature-extraction + :target: https://medomicslab.gitbook.io/mediml-app-docs/radiomics/feature-extraction .. image:: /figures/MEDimage-app-dm.png :width: 500 - :target: https://medomics-udes.gitbook.io/medomicslab-docs/tutorials/radiomics/data-processing + :target: https://medomicslab.gitbook.io/mediml-app-docs/radiomics/data-processing .. toctree:: :maxdepth: 2 diff --git a/docs/input_data.rst b/docs/input_data.rst index 8679c00..9b20a44 100644 --- a/docs/input_data.rst +++ b/docs/input_data.rst @@ -1,7 +1,7 @@ Input Data ========== -``MEDimage`` package accepts two formats of input data: `NIfTI `__ +``MEDiml`` package accepts two formats of input data: `NIfTI `__ and `DICOM `__. Each format has its own conventions that need to be followed. The following sections describe the norms and the conventions for each format and we recommend you process your dataset in a way that respects them. @@ -26,12 +26,12 @@ B. **RTstruct** RTstruct files define the area of significance and hold information about each region of interest (ROI). The RTstruct files are associated with their imaging volume using the ``(0020,000E) Series Instance UID`` or the ``(0020,0052) Frame of Reference UID`` found in the file's header. - ``MEDimage`` package recommends the following: + ``MEDiml`` package recommends the following: - **Patient ID**: Same conventions and recommendations as the DICOM image. - **Series description**: Same conventions and recommendations as the DICOM image. - **ROI name**: Only found in DICOM RTstruct files and referenced in each element (each ROI) of the ``(3006,0020) Structure Set ROI Sequence`` list of - the DICOM header, under the attribute ``(3006,0026) ROI Name`` which is a name given to each region of interest (ROI). ``MEDimage`` has no + the DICOM header, under the attribute ``(3006,0026) ROI Name`` which is a name given to each region of interest (ROI). ``MEDiml`` has no conventions over this field, but we recommend renaming each ROI name in a simple and logic way to differentiate them from each other. It is very important to keep track of all the ROIs in your dataset since they need to be specified in the :doc:`../csv_file` of the dataset under the ``ROIName`` column to be used later in your radiomics analysis. @@ -40,21 +40,21 @@ NIfTI ----- The NIfTI format is a simple format that only contains the image itself. Unlike DICOM, the NIfTI format does contain any -information about the regions of interest (ROI) so it needs to be provided in other separate files. In order for ``MEDimage`` to read a NIfTI scan +information about the regions of interest (ROI) so it needs to be provided in other separate files. In order for ``MEDMEDimlimage`` to read a NIfTI scan files, they need to be put in the same folder with the following names: - ``'PatientID__SeriesDescription(ROILabel).Modality.nii.gz'``: The image itself. For example: ``'STS-McGill-001__T1(GTV).MRscan.nii.gz'``. - ``'PatientID__SeriesDescription(ROIname).ROI.nii.gz'``: The ROI or the mask of the image. This file should contain a binary mask of the ROI. For example: ``'STS-McGill-001__T1(GTV_Mass).ROI.nii.gz'``. -The following figure sums up the ``MEDimage`` logic in reading data for both formats: +The following figure sums up the ``MEDiml`` logic in reading data for both formats: .. image:: /figures/InputDataSummary.png :width: 1000 :align: center If these conventions are followed, the ``DataManager`` class will be able to read the data and create the ``MEDscan`` objects that will be used -in the radiomics analysis with no further intervention from the user. For instance, ``MEDimage`` package is capable of automatically updating +in the radiomics analysis with no further intervention from the user. For instance, ``MEDiml`` package is capable of automatically updating the fields of all the DICOM files as long as the dataset is organized in the following way: :: diff --git a/docs/learning.rst b/docs/learning.rst index 72a0833..ddbcf6d 100644 --- a/docs/learning.rst +++ b/docs/learning.rst @@ -3,42 +3,42 @@ Learning DataCleaner ------------------------------------- -.. automodule:: MEDimage.learning.DataCleaner +.. automodule:: MEDiml.learning.DataCleaner :members: :undoc-members: :show-inheritance: Desgin experiment ------------------------------------- -.. automodule:: MEDimage.learning.DesignExperiment +.. automodule:: MEDiml.learning.DesignExperiment :members: :undoc-members: :show-inheritance: Feature set reduction ------------------------------------- -.. automodule:: MEDimage.learning.FSR +.. automodule:: MEDiml.learning.FSR :members: :undoc-members: :show-inheritance: Normalization ------------------------------------- -.. automodule:: MEDimage.learning.Normalization +.. automodule:: MEDiml.learning.Normalization :members: :undoc-members: :show-inheritance: Radiomics Learner ------------------------------------- -.. automodule:: MEDimage.learning.RadiomicsLearner +.. automodule:: MEDiml.learning.RadiomicsLearner :members: :undoc-members: :show-inheritance: Results ------------------------------------- -.. automodule:: MEDimage.learning.Results +.. automodule:: MEDiml.learning.Results :members: :undoc-members: :show-inheritance: \ No newline at end of file diff --git a/docs/modules.rst b/docs/modules.rst index 667f556..9729fc6 100644 --- a/docs/modules.rst +++ b/docs/modules.rst @@ -1,4 +1,4 @@ -MEDimage +MEDiml ======== .. toctree:: diff --git a/docs/processing.rst b/docs/processing.rst index b8ffe72..6f56feb 100644 --- a/docs/processing.rst +++ b/docs/processing.rst @@ -5,7 +5,7 @@ Processing compute\_suv\_map -------------------------------------------- -.. automodule:: MEDimage.processing.compute_suv_map +.. automodule:: MEDiml.processing.compute_suv_map :members: :undoc-members: :show-inheritance: @@ -13,7 +13,7 @@ compute\_suv\_map discretization ----------------------------------------- -.. automodule:: MEDimage.processing.discretisation +.. automodule:: MEDiml.processing.discretisation :members: :undoc-members: :show-inheritance: @@ -21,7 +21,7 @@ discretization interpolation ----------------------------------------- -.. automodule:: MEDimage.processing.interpolation +.. automodule:: MEDiml.processing.interpolation :members: :undoc-members: :show-inheritance: @@ -29,7 +29,7 @@ interpolation resegmentation ----------------------------------------- -.. automodule:: MEDimage.processing.resegmentation +.. automodule:: MEDiml.processing.resegmentation :members: :undoc-members: :show-inheritance: @@ -37,7 +37,7 @@ resegmentation segmentation ----------------------------------------- -.. automodule:: MEDimage.processing.segmentation +.. automodule:: MEDiml.processing.segmentation :members: :undoc-members: :show-inheritance: diff --git a/docs/tutorials.rst b/docs/tutorials.rst index 703f306..d842680 100644 --- a/docs/tutorials.rst +++ b/docs/tutorials.rst @@ -20,24 +20,24 @@ CSV file -------- Most tutorials, such as the :ref:`BatchExtractor tutorial `, utilize multiple scans, each with its CSV file. - ``MEDimage`` requires a CSV file for each dataset; details can be found in the :doc:`../csv_file`. - Examples are available in ``MEDimage/notebooks/tutorial/csv``. + ``MEDiml`` requires a CSV file for each dataset; details can be found in the :doc:`../csv_file`. + Examples are available in ``MEDiml/notebooks/tutorial/csv``. .. note:: - Future versions of ``MEDimage`` aim to automate the creation of these CSV files for each dataset. + Future versions of ``MEDiml`` aim to automate the creation of these CSV files for each dataset. Configuration file ------------------ - To use ``MEDimage``, a configuration file is always required. An example file is available in the GitHub repository - (``MEDimage/notebooks/tutorial/settings/MEDimage-Tutorial.json``), and documentation is provided :doc:`../configurations_file`. + To use ``MEDiml``, a configuration file is always required. An example file is available in the GitHub repository + (``MEDiml/notebooks/tutorial/settings/MEDiml-Tutorial.json``), and documentation is provided :doc:`../configurations_file`. Different JSON configuration files are used for each case; for example, specific JSON configurations for every - `IBSI `__ test are available in ``MEDimage/notebooks/ibsi/settings``. + `IBSI `__ test are available in ``MEDiml/notebooks/ibsi/settings``. DataManager =========== - The ``DataManager`` plays an important role in ``MEDimage``. The class is capable of processing raw `DICOM `__ + The ``DataManager`` plays an important role in ``MEDiml``. The class is capable of processing raw `DICOM `__ and `NIfTI `__ and converting them in into ``MEDscan`` class objects. It includes pre-radiomics analysis, determining the best intensity ranges and voxel dimension rescaling parameters for a given dataset. This analysis is essential, as highlighted in this `article `__ , which investigates how intensity @@ -45,10 +45,10 @@ DataManager The tutorial for DataManager is available here.: |DataManager_image_badge| - You can also find this tutorial on the repository ``MEDimage/notebooks/tutorial/DataManager-Tutorial.ipynb``. + You can also find this tutorial on the repository ``MEDiml/notebooks/tutorial/DataManager-Tutorial.ipynb``. .. |DataManager_image_badge| image:: https://colab.research.google.com/assets/colab-badge.png - :target: https://colab.research.google.com/github/MahdiAll99/MEDimage/blob/main/notebooks/tutorial/DataManager-Tutorial.ipynb + :target: https://colab.research.google.com/github/MEDomicsLab/MEDiml/blob/main/notebooks/tutorial/DataManager-Tutorial.ipynb .. image:: /figures/DataManager-overview.png :width: 800 @@ -57,32 +57,32 @@ DataManager MEDscan Class ============== - In MEDimage, the ``MEDscan`` class is a Python object that maintains data and information about the dataset, particularly related to scans processed + In MEDiml, the ``MEDscan`` class is a Python object that maintains data and information about the dataset, particularly related to scans processed from NIfTI or DICOM data. It can manage parameters used in processing, filtering, and extraction, reading from JSON files and updating all relevant - attributes. Many other useful functionalities are detailed in this tutorial: |MEDimage_image_badge| + attributes. Many other useful functionalities are detailed in this tutorial: |MEDiml_image_badge| - You can also find this tutorial on the repository ``MEDimage/notebooks/tutorial/MEDimage-Tutorial.ipynb``. + You can also find this tutorial on the repository ``MEDiml/notebooks/tutorial/MEDiml-Tutorial.ipynb``. -.. |MEDimage_image_badge| image:: https://colab.research.google.com/assets/colab-badge.png - :target: https://colab.research.google.com/github/MahdiAll99/MEDimage/blob/main/notebooks/tutorial/MEDimage-Tutorial.ipynb +.. |MEDiml_image_badge| image:: https://colab.research.google.com/assets/colab-badge.png + :target: https://colab.research.google.com/github/MEDomicsLab/MEDiml/blob/main/notebooks/tutorial/MEDiml-Tutorial.ipynb Single-scan demo ================ - This demo provides a step-by-step guide to processing and extracting features for a single scan using ``MEDimage``. It covers various use cases, - from initial processing steps to the extraction of features. The demo is perfect for learning how to use MEDimage for single-scan feature extraction. + This demo provides a step-by-step guide to processing and extracting features for a single scan using ``MEDiml``. It covers various use cases, + from initial processing steps to the extraction of features. The demo is perfect for learning how to use MEDiml for single-scan feature extraction. The interactive Colab notebook for the demo is available here: |Glioma_demo_image_badge| - You can also find it on the repository ``MEDimage/notebooks/demo/Glioma-Demo.ipynb``. + You can also find it on the repository ``MEDiml/notebooks/demo/Glioma-Demo.ipynb``. .. |Glioma_demo_image_badge| image:: https://colab.research.google.com/assets/colab-badge.png - :target: https://colab.research.google.com/github/MahdiAll99/MEDimage/blob/main/notebooks/demo/Glioma-Demo.ipynb + :target: https://colab.research.google.com/github/MEDomicsLab/MEDiml/blob/main/notebooks/demo/Glioma-Demo.ipynb BatchExtractor ============== - ``MEDimage`` facilitates batch feature extraction through the ``BatchExtractor`` class, which streamlines the following workflow: + ``MEDiml`` facilitates batch feature extraction through the ``BatchExtractor`` class, which streamlines the following workflow: .. image:: /figures/BatchExtractor-overview.png :width: 800 @@ -90,14 +90,14 @@ BatchExtractor This class creates batches of scans and performs full extraction of all radiomics family features, saving them in tables and JSON files. To run a batch extraction, simply set the path to your dataset and the path to your dataset's :doc:`../csv_file` of regions of interest. - (check example `here `__). + (check example `here `__). Learn more in the interactive Colab notebook here: |BatchExtractor_image_badge| - You can also find it on the repository ``MEDimage/notebooks/tutorial/BatchExtractor-Tutorial.ipynb``. + You can also find it on the repository ``MEDiml/notebooks/tutorial/BatchExtractor-Tutorial.ipynb``. .. |BatchExtractor_image_badge| image:: https://colab.research.google.com/assets/colab-badge.png - :target: https://colab.research.google.com/github/MahdiAll99/MEDimage/blob/main/notebooks/tutorial/BatchExtractor-Tutorial.ipynb + :target: https://colab.research.google.com/github/MEDomicsLab/MEDiml/blob/main/notebooks/tutorial/BatchExtractor-Tutorial.ipynb Learning ======== @@ -105,7 +105,7 @@ Learning Overview -------- - ``MEDimage`` offers a learning module for training a machine learning model on extracted features. The module handles features cleaning, normalization, + ``MEDiml`` offers a learning module for training a machine learning model on extracted features. The module handles features cleaning, normalization, selection, model training, and testing. The workflow is summarized in the following image: .. image:: /figures/LearningWorkflow.png @@ -114,22 +114,22 @@ Overview Similar to the extraction module, the learning module also uses multiple JSON configuration files to set the parameters of the learning process. Details about the configuration files, are available here: :doc:`../configurations_file`. You can also find an example of these files in the - GitHub repository (``MEDimage/tree/learning/notebooks/tutorial/learning/settings``). + GitHub repository (``MEDiml/tree/learning/notebooks/tutorial/learning/settings``). A tutorial is provided in this notebook: |Learning_image_badge| - You can also find it on the repository ``MEDimage/notebooks/tutorial/Learning-Tutorial.ipynb``. + You can also find it on the repository ``MEDiml/notebooks/tutorial/Learning-Tutorial.ipynb``. .. |Learning_image_badge| image:: https://colab.research.google.com/assets/colab-badge.png - :target: https://colab.research.google.com/github/MahdiAll99/MEDimage/blob/learning/notebooks/tutorial/Learning-Tutorial.ipynb + :target: https://colab.research.google.com/github/MEDomicsLab/MEDiml/blob/learning/notebooks/tutorial/Learning-Tutorial.ipynb How to setup your experiment ---------------------------- - To fully use the ``MEDimage`` functionalities, you must follow certain norms and guidelines: + To fully use the ``MEDiml`` functionalities, you must follow certain norms and guidelines: **Experiment Name**: - The experiment name is the label used to identify your machine learning experiment. In ``MEDimage`` we use the following format for the experiment name: + The experiment name is the label used to identify your machine learning experiment. In ``MEDiml`` we use the following format for the experiment name: ``__``. This format is depicted in the following image: .. image:: /figures/ExperimentNameBreakdown.png @@ -139,7 +139,7 @@ How to setup your experiment Results Analysis ---------------- - It is worth noting that to use most functionalities of the results analsys part you must follow the format for the experiment. + It is worth noting that to use most functionalities of the results analysis part you must follow the format for the experiment. Analysis of results involves different key steps: diff --git a/docs/utils.rst b/docs/utils.rst index d523489..7a3a288 100644 --- a/docs/utils.rst +++ b/docs/utils.rst @@ -4,7 +4,7 @@ Utils batch\_patients ------------------------------------- -.. automodule:: MEDimage.utils.batch_patients +.. automodule:: MEDiml.utils.batch_patients :members: :undoc-members: :show-inheritance: @@ -12,7 +12,7 @@ batch\_patients create\_radiomics\_table ---------------------------------------------- -.. automodule:: MEDimage.utils.create_radiomics_table +.. automodule:: MEDiml.utils.create_radiomics_table :members: :undoc-members: :show-inheritance: @@ -20,7 +20,7 @@ create\_radiomics\_table data\_frame\_export ----------------------------------------- -.. automodule:: MEDimage.utils.data_frame_export +.. automodule:: MEDiml.utils.data_frame_export :members: :undoc-members: :show-inheritance: @@ -28,7 +28,7 @@ data\_frame\_export find\_process\_names ------------------------------------------ -.. automodule:: MEDimage.utils.find_process_names +.. automodule:: MEDiml.utils.find_process_names :members: :undoc-members: :show-inheritance: @@ -36,7 +36,7 @@ find\_process\_names get\_file\_paths -------------------------------------- -.. automodule:: MEDimage.utils.get_file_paths +.. automodule:: MEDiml.utils.get_file_paths :members: :undoc-members: :show-inheritance: @@ -44,7 +44,7 @@ get\_file\_paths get\_institutions\_from\_ids -------------------------------------------------- -.. automodule:: MEDimage.utils.get_institutions_from_ids +.. automodule:: MEDiml.utils.get_institutions_from_ids :members: :undoc-members: :show-inheritance: @@ -52,7 +52,7 @@ get\_institutions\_from\_ids get\_patient\_id\_from\_scan\_name -------------------------------------------------------- -.. automodule:: MEDimage.utils.get_patient_id_from_scan_name +.. automodule:: MEDiml.utils.get_patient_id_from_scan_name :members: :undoc-members: :show-inheritance: @@ -60,7 +60,7 @@ get\_patient\_id\_from\_scan\_name get\_patient\_names ----------------------------------------- -.. automodule:: MEDimage.utils.get_patient_names +.. automodule:: MEDiml.utils.get_patient_names :members: :undoc-members: :show-inheritance: @@ -68,7 +68,7 @@ get\_patient\_names get\_radiomic\_names ------------------------------------------ -.. automodule:: MEDimage.utils.get_radiomic_names +.. automodule:: MEDiml.utils.get_radiomic_names :members: :undoc-members: :show-inheritance: @@ -76,7 +76,7 @@ get\_radiomic\_names get\_scan\_name\_from\_rad\_name ------------------------------------------------------ -.. automodule:: MEDimage.utils.get_scan_name_from_rad_name +.. automodule:: MEDiml.utils.get_scan_name_from_rad_name :members: :undoc-members: :show-inheritance: @@ -84,7 +84,7 @@ get\_scan\_name\_from\_rad\_name image\_reader\_SITK ----------------------------------------- -.. automodule:: MEDimage.utils.image_reader_SITK +.. automodule:: MEDiml.utils.image_reader_SITK :members: :undoc-members: :show-inheritance: @@ -92,7 +92,7 @@ image\_reader\_SITK image\_volume\_obj ---------------------------------------- -.. automodule:: MEDimage.utils.image_volume_obj +.. automodule:: MEDiml.utils.image_volume_obj :members: :undoc-members: :show-inheritance: @@ -100,7 +100,7 @@ image\_volume\_obj imref --------------------------- -.. automodule:: MEDimage.utils.imref +.. automodule:: MEDiml.utils.imref :members: :undoc-members: :show-inheritance: @@ -108,7 +108,7 @@ imref initialize\_features\_names ------------------------------------------------- -.. automodule:: MEDimage.utils.initialize_features_names +.. automodule:: MEDiml.utils.initialize_features_names :members: :undoc-members: :show-inheritance: @@ -116,7 +116,7 @@ initialize\_features\_names inpolygon ------------------------------- -.. automodule:: MEDimage.utils.inpolygon +.. automodule:: MEDiml.utils.inpolygon :members: :undoc-members: :show-inheritance: @@ -124,7 +124,7 @@ inpolygon interp3 ----------------------------- -.. automodule:: MEDimage.utils.interp3 +.. automodule:: MEDiml.utils.interp3 :members: :undoc-members: :show-inheritance: @@ -132,7 +132,7 @@ interp3 json\_utils --------------------------------- -.. automodule:: MEDimage.utils.json_utils +.. automodule:: MEDiml.utils.json_utils :members: :undoc-members: :show-inheritance: @@ -140,7 +140,7 @@ json\_utils mode -------------------------- -.. automodule:: MEDimage.utils.mode +.. automodule:: MEDiml.utils.mode :members: :undoc-members: :show-inheritance: @@ -148,7 +148,7 @@ mode parse\_contour\_string -------------------------------------------- -.. automodule:: MEDimage.utils.parse_contour_string +.. automodule:: MEDiml.utils.parse_contour_string :members: :undoc-members: :show-inheritance: @@ -156,7 +156,7 @@ parse\_contour\_string save\_MEDscan ------------------------------------ -.. automodule:: MEDimage.utils.save_MEDscan +.. automodule:: MEDiml.utils.save_MEDscan :members: :undoc-members: :show-inheritance: @@ -164,7 +164,7 @@ save\_MEDscan strfind ----------------------------- -.. automodule:: MEDimage.utils.strfind +.. automodule:: MEDiml.utils.strfind :members: :undoc-members: :show-inheritance: @@ -172,7 +172,7 @@ strfind textureTools ---------------------------------- -.. automodule:: MEDimage.utils.textureTools +.. automodule:: MEDiml.utils.textureTools :members: :undoc-members: :show-inheritance: @@ -180,7 +180,7 @@ textureTools write\_radiomics\_csv ------------------------------------------- -.. automodule:: MEDimage.utils.write_radiomics_csv +.. automodule:: MEDiml.utils.write_radiomics_csv :members: :undoc-members: :show-inheritance: diff --git a/docs/wrangling.rst b/docs/wrangling.rst index 9af4995..d000ddd 100644 --- a/docs/wrangling.rst +++ b/docs/wrangling.rst @@ -4,7 +4,7 @@ Wrangling DataManager ------------------------------------- -.. automodule:: MEDimage.wrangling.DataManager +.. automodule:: MEDiml.wrangling.DataManager :members: :undoc-members: :show-inheritance: @@ -12,7 +12,7 @@ DataManager ProcessDICOM ----------------------------------------- -.. automodule:: MEDimage.wrangling.ProcessDICOM +.. automodule:: MEDiml.wrangling.ProcessDICOM :members: :undoc-members: :show-inheritance: diff --git a/environment.yml b/environment.yml index 02d97a5..b18943b 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,4 @@ -name: medimage +name: mediml channels: - conda-forge diff --git a/notebooks/README.md b/notebooks/README.md index 9358d47..ccd45b6 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -1,4 +1,4 @@ -# MEDimage demo, ibsi tests and tutorials +# MEDiml demo, ibsi tests and tutorials We have made many notebooks available in this folder to clear the way for the use of the package. In order to run these notebooks you must have the right datasets for each notebook. To easily do so, run the following command from the parent folder: @@ -18,4 +18,4 @@ The *demo* folder contains one notebook that demonstrates in a brief way the dif ## tutorials folder -The *tutorials* folder contains notebooks explaining the use of ``DataManager``, ``MEDimage`` and ``BatchExtractor`` classes, these three classes highly participate in the functioning of the package so we recommend taking the time to follow the tutorials. \ No newline at end of file +The *tutorials* folder contains notebooks explaining the use of ``DataManager``, ``MEDiml`` and ``BatchExtractor`` classes, these three classes highly participate in the functioning of the package so we recommend taking the time to follow the tutorials. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 8fcb5f9..33e6293 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,17 @@ [tool.poetry] -name = "medimage-pkg" +name = "mediml" version = "0.9.8" -description = "MEDimage is a Python package for processing and extracting features from medical images" +description = "MEDiml is a Python package for processing and extracting features from medical images" authors = ["MEDomics Consortium "] license = "GPL-3.0" readme = "README.md" -homepage = "https://medimage.app/" -repository = "https://github.com/MEDomics-UdeS/MEDimage/" +homepage = "https://mediml.app/" +repository = "https://github.com/MEDomicsLab/MEDiml/" keywords = ["python", "ibsi", "medical-imaging", "cancer-imaging-research", "radiomics", "medical-image-analysis", "features-extraction", "radiomics-extraction", "radiomics-features", "radiomics-analysis"] -packages = [ {include = "MEDimage"} ] +packages = [ {include = "MEDiml"} ] [tool.poetry.dependencies] python = ">=3.8.0,<=3.10" diff --git a/scripts/download_data.py b/scripts/download_data.py index 9f061ff..191ca43 100644 --- a/scripts/download_data.py +++ b/scripts/download_data.py @@ -8,7 +8,7 @@ def main(full_sts: bool, subset: bool) -> None: """ - Downloads MEDimage data for testing, tutorials and demo and organizes it in the right folders. + Downloads MEDiml data for testing, tutorials and demo and organizes it in the right folders. Args: full_sts (bool): if ``True`` will not download the STS data (large size). @@ -24,17 +24,17 @@ def main(full_sts: bool, subset: bool) -> None: "https://sandbox.zenodo.org/records/45640/files/MEDimage-Dataset-No-STS.zip?download=1", out=os.getcwd()) except Exception as e: - print("MEDimage-Dataset-No-STS.zip download failed, error:", e) + print("MEDiml-Dataset-No-STS.zip download failed, error:", e) # unzip data print("\n================ Extracting first part of data ================") try: - with zipfile.ZipFile(os.getcwd() + "/MEDimage-Dataset-No-STS.zip", 'r') as zip_ref: + with zipfile.ZipFile(os.getcwd() + "/MEDiml-Dataset-No-STS.zip", 'r') as zip_ref: zip_ref.extractall(os.getcwd()) # delete zip file after extraction - os.remove(os.getcwd() + "/MEDimage-Dataset-No-STS.zip") + os.remove(os.getcwd() + "/MEDiml-Dataset-No-STS.zip") except Exception as e: - print("MEDimage-Dataset-No-STS.zip extraction failed, error:", e) + print("MEDiml-Dataset-No-STS.zip extraction failed, error:", e) # Organize data in the right folders # ibsi tests data organization @@ -90,17 +90,17 @@ def main(full_sts: bool, subset: bool) -> None: out=os.getcwd()) pass except Exception as e: - print("MEDimage-STS-Dataset.zip download failed, error:", e) + print("MEDiml-STS-Dataset.zip download failed, error:", e) # unzip data print("\n================ Extracting second part of data ================") try: - with zipfile.ZipFile(os.getcwd() + "/MEDimage-STS-Dataset.zip", 'r') as zip_ref: + with zipfile.ZipFile(os.getcwd() + "/MEDiml-STS-Dataset.zip", 'r') as zip_ref: zip_ref.extractall(os.getcwd()) # remove zip file after extraction - os.remove(os.getcwd() + "/MEDimage-STS-Dataset.zip") + os.remove(os.getcwd() + "/MEDiml-STS-Dataset.zip") except Exception as e: - print("MEDimage-STS-Dataset.zip extraction failed, error:", e) + print("MEDiml-STS-Dataset.zip extraction failed, error:", e) # organize data in the right folder print("\n================== Organizing data in folders ==================") @@ -118,31 +118,31 @@ def main(full_sts: bool, subset: bool) -> None: out=os.getcwd()) pass except Exception as e: - print("MEDimage-STS-Dataset-Subset.zip download failed, error:", e) + print("MEDiml-STS-Dataset-Subset.zip download failed, error:", e) # unzip data print("\n================ Extracting second part of data ================") try: - with zipfile.ZipFile(os.getcwd() + "/MEDimage-STS-Dataset-Subset.zip", 'r') as zip_ref: + with zipfile.ZipFile(os.getcwd() + "/MEDiml-STS-Dataset-Subset.zip", 'r') as zip_ref: zip_ref.extractall(os.getcwd()) # remove zip file after extraction - os.remove(os.getcwd() + "/MEDimage-STS-Dataset-Subset.zip") + os.remove(os.getcwd() + "/MEDiml-STS-Dataset-Subset.zip") except Exception as e: - print("MEDimage-STS-Dataset-Subset.zip extraction failed, error:", e) + print("MEDiml-STS-Dataset-Subset.zip extraction failed, error:", e) # organize data in the right folder print("\n================== Organizing data in folders ==================") try: - shutil.move(os.getcwd() + "/MEDimage-STS-Dataset-Subset", + shutil.move(os.getcwd() + "/MEDiml-STS-Dataset-Subset", os.getcwd() + "/notebooks" + "/tutorial" + "/data" + "/DICOM-STS") except Exception as e: - print("Failed to move MEDimage-STS-Dataset-Subset folder, error:", e) + print("Failed to move MEDiml-STS-Dataset-Subset folder, error:", e) if __name__ == "__main__": # setting up arguments: parser = argparse.ArgumentParser(description='Download dataset "\ - "for MEDimage package tests, tutorials and other demos.') + "for MEDiml package tests, tutorials and other demos.') parser.add_argument("--full-sts", default=False, action='store_true', help="If specified, will download the full STS data used in tutorials. Defaults to False.") parser.add_argument("--subset", default=True, action='store_true', diff --git a/scripts/process_dataset.py b/scripts/process_dataset.py index 5fb92c1..ee2512f 100644 --- a/scripts/process_dataset.py +++ b/scripts/process_dataset.py @@ -35,7 +35,7 @@ def main(path_dataset: Union[str, Path]) -> None: if __name__ == "__main__": # setting up arguments: - parser = argparse.ArgumentParser(description='Re-organize dataset to follow MEDimage package conventions.') + parser = argparse.ArgumentParser(description='Re-organize dataset to follow MEDiml package conventions.') parser.add_argument("--path-dataset", required=True, help="Path to your dataset folder.") args = parser.parse_args() diff --git a/setup.py b/setup.py index a9502f4..1cd1e6d 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ # Check if current python installation is >= 3.8 if sys.version_info < (3, 8, 0): - raise Exception("MEDimage requires python 3.8 or later") + raise Exception("MEDiml requires python 3.8 or later") with open("README.md", encoding='utf-8') as f: long_description = f.read() @@ -13,17 +13,17 @@ requirements = f.readlines() setup( - name="MEDimage", + name="MEDiml", version="0.9.8", author="MEDomics consortium", author_email="medomics.info@gmail.com", description="Python Open-source package for medical images processing and radiomic features extraction", long_description=long_description, long_description_content_type="text/markdown", - url="https://github.com/MahdiAll99/MEDimage", + url="https://github.com/MEDomicsLab/MEDiml", project_urls={ 'Documentation': 'https://medimage.readthedocs.io/en/latest/index.html', - 'Github': 'https://github.com/MahdiAll99/MEDimage' + 'Github': 'https://github.com/MEDomicsLab/MEDiml' }, classifiers=[ 'Development Status :: 3 - Alpha', diff --git a/tests/test_extraction.py b/tests/test_extraction.py index 8e2b17f..0fc1b04 100644 --- a/tests/test_extraction.py +++ b/tests/test_extraction.py @@ -3,10 +3,10 @@ import numpy as np -MODULE_DIR = os.path.dirname(os.path.abspath('./MEDimage/')) +MODULE_DIR = os.path.dirname(os.path.abspath('./MEDiml/')) sys.path.append(MODULE_DIR) -import MEDimage +import MEDiml class TestExtraction: @@ -82,20 +82,20 @@ def __get_random_roi(self): def test_morph_features(self): phantom = self.__get_phantom() roi = self.__get_random_roi() - morph = MEDimage.biomarkers.morph.extract_all( + morph = MEDiml.biomarkers.morph.extract_all( vol=phantom, mask_int=roi, mask_morph=roi, res=[2, 2, 2], intensity_type="arbitrary" ) - morph_vol = MEDimage.biomarkers.morph.vol( + morph_vol = MEDiml.biomarkers.morph.vol( vol=phantom, mask_int=roi, mask_morph=roi, res=[2, 2, 2] ) - surface_area = MEDimage.biomarkers.morph.area( + surface_area = MEDiml.biomarkers.morph.area( vol=phantom, mask_int=roi, mask_morph=roi, @@ -109,18 +109,18 @@ def test_morph_features(self): def test_stats_features(self): phantom = self.__get_phantom() roi = self.__get_random_roi() - vol_int_re = MEDimage.processing.roi_extract( + vol_int_re = MEDiml.processing.roi_extract( vol=phantom, roi=roi ) - stats = MEDimage.biomarkers.stats.extract_all( + stats = MEDiml.biomarkers.stats.extract_all( vol=vol_int_re, intensity_type="definite" ) - kurt = MEDimage.biomarkers.stats.kurt( + kurt = MEDiml.biomarkers.stats.kurt( vol=vol_int_re, ) - skewness = MEDimage.biomarkers.stats.skewness( + skewness = MEDiml.biomarkers.stats.skewness( vol=vol_int_re, ) assert kurt == stats["Fstat_kurt"] diff --git a/tests/test_filtering.py b/tests/test_filtering.py index 8844bee..e514031 100644 --- a/tests/test_filtering.py +++ b/tests/test_filtering.py @@ -3,10 +3,10 @@ import numpy as np -MODULE_DIR = os.path.dirname(os.path.abspath('./MEDimage/')) +MODULE_DIR = os.path.dirname(os.path.abspath('./MEDiml/')) sys.path.append(MODULE_DIR) -from MEDimage.filters.gabor import apply_gabor +from MEDiml.filters.gabor import apply_gabor def test_gabor():