MEDscan
MEDscan
- class MEDimage.MEDscan.MEDscan(medscan=None)[source]
Bases:
object
Organizes all scan data (patientID, imaging data, scan type…).
- patientID
Patient ID.
- Type:
str
- type
Scan type (MRscan, CTscan…).
- Type:
str
- format
Scan file format. Either ‘npy’ or ‘nifti’.
- Type:
str
- dicomH
DICOM header.
- Type:
pydicom.dataset.FileDataset
- data[source]
Instance of MEDscan.data inner class.
- Type:
MEDscan.data
- class Params[source]
Bases:
object
Organizes all processing, filtering and features extraction parameters
- class Filter(filter_type: str = '')[source]
Bases:
object
Organizes all filtering parameters
- class Gabor(sigma: float = 0.0, _lambda: float = 0.0, gamma: float = 0.0, theta: str = '', rot_invariance: bool = False, orthogonal_rot: bool = False, name_save: str = '', padding: str = '')[source]
Bases:
object
Organizes the gabor filter parameters
- __init__(sigma: float = 0.0, _lambda: float = 0.0, gamma: float = 0.0, theta: str = '', rot_invariance: bool = False, orthogonal_rot: bool = False, name_save: str = '', padding: str = '') None [source]
Constructor of the Gabor class.
- Parameters:
sigma (float) – Float of the sigma value.
_lambda (float) – Float of the lambda value.
gamma (float) – Float of the gamma value.
theta (str) – String of the theta angle value.
rot_invariance (bool) – If True the filter will be rotation invariant.
orthogonal_rot (bool) – If True will compute average response over orthogonal planes.
name_save (str) – Specific name added to final extraction results file.
padding (str) – padding mode.
- Returns:
None.
- init_from_json(params: Dict) None [source]
Updates class attributes from json file.
- Parameters:
params (Dict) – Dictionary of the gabor filter parameters.
- Returns:
None.
- class Laws(config: List = [], energy_distance: int = 0, energy_image: bool = False, rot_invariance: bool = False, orthogonal_rot: bool = False, name_save: str = '', padding: str = '')[source]
Bases:
object
Organizes the laws filter parameters
- __init__(config: List = [], energy_distance: int = 0, energy_image: bool = False, rot_invariance: bool = False, orthogonal_rot: bool = False, name_save: str = '', padding: str = '') None [source]
Constructor of the Laws class.
- Parameters:
config (List) – Configuration of the Laws filter, for ex: [‘E5’, ‘L5’, ‘E5’].
energy_distance (int) – Chebyshev distance.
energy_image (bool) – If True will compute the Laws texture energy image.
rot_invariance (bool) – If True the filter will be rotation invariant.
orthogonal_rot (bool) – If True will compute average response over orthogonal planes.
name_save (str) – Specific name added to final extraction results file.
padding (str) – padding mode.
- Returns:
None.
- init_from_json(params: Dict) None [source]
Updates class attributes from json file.
- Parameters:
params (Dict) – Dictionary of the laws filter parameters.
- Returns:
None.
- class Log(ndims: int = 0, sigma: float = 0.0, padding: str = '', orthogonal_rot: bool = False, name_save: str = '')[source]
Bases:
object
Organizes the Log filter parameters
- __init__(ndims: int = 0, sigma: float = 0.0, padding: str = '', orthogonal_rot: bool = False, name_save: str = '') None [source]
Constructor of the Log class.
- Parameters:
ndims (int) – Filter dimension.
sigma (float) – Float of the sigma value.
padding (str) – padding mode.
orthogonal_rot (bool) – If True will compute average response over orthogonal planes.
name_save (str) – Specific name added to final extraction results file.
- Returns:
None.
- init_from_json(params: Dict) None [source]
Updates class attributes from json file.
- Parameters:
params (Dict) – Dictionary of the Log filter parameters.
- Returns:
None.
- class Mean(ndims: int = 0, name_save: str = '', padding: str = '', size: int = 0, orthogonal_rot: bool = False)[source]
Bases:
object
Organizes the Mean filter parameters
- __init__(ndims: int = 0, name_save: str = '', padding: str = '', size: int = 0, orthogonal_rot: bool = False) None [source]
Constructor of the Mean class.
- Parameters:
ndims (int) – Filter dimension.
name_save (str) – Specific name added to final extraction results file.
padding (str) – padding mode.
size (int) – Filter size.
- Returns:
None.
- init_from_json(params: Dict) None [source]
Updates class attributes from json file.
- Parameters:
params (Dict) – Dictionary of the Mean filter parameters.
- Returns:
None.
- class Textural(family: str = '', size: int = 0, discretization: dict = {}, local: bool = False, name_save: str = '')[source]
Bases:
object
Organizes the Textural filters parameters
- __init__(family: str = '', size: int = 0, discretization: dict = {}, local: bool = False, name_save: str = '') None [source]
Constructor of the Textural class.
- Parameters:
family (str, optional) – The family of the textural filter.
size (int, optional) – The filter size.
discretization (dict, optional) – The discretization parameters.
local (bool, optional) – If true, the discretization will be computed locally, else globally.
name_save (str, optional) – Specific name added to final extraction results file.
- Returns:
None.
- init_from_json(params: Dict) None [source]
Updates class attributes from json file.
- Parameters:
params (Dict) – Dictionary of the wavelet filter parameters.
- Returns:
None.
- class Wavelet(ndims: int = 0, name_save: str = '', basis_function: str = '', subband: str = '', level: int = 0, rot_invariance: bool = False, padding: str = '')[source]
Bases:
object
Organizes the Wavelet filter parameters
- __init__(ndims: int = 0, name_save: str = '', basis_function: str = '', subband: str = '', level: int = 0, rot_invariance: bool = False, padding: str = '') None [source]
Constructor of the Wavelet class.
- Parameters:
ndims (int) – Dimension of the filter.
name_save (str) – Specific name added to final extraction results file.
basis_function (str) – Wavelet basis function.
subband (str) – Wavelet subband.
level (int) – Decomposition level.
rot_invariance (bool) – If True the filter will be rotation invariant.
padding (str) – padding mode.
- Returns:
None.
- init_from_json(params: Dict) None [source]
Updates class attributes from json file.
- Parameters:
params (Dict) – Dictionary of the wavelet filter parameters.
- Returns:
None.
- __init__(filter_type: str = '') None [source]
Constructor of the Filter class.
- Parameters:
filter_type (str) – Type of the filter that will be used (Must be ‘mean’, ‘log’, ‘laws’, ‘gabor’ or ‘wavelet’).
- Returns:
None.
- class Process(**kwargs)[source]
Bases:
object
Organizes all processing parameters.
- __init__(**kwargs) None [source]
Constructor of the Process class.
- init_from_json(path_to_json: Path | str) None [source]
Updates class attributes from json file.
- Parameters:
path_to_json (Union[Path, str]) – Path to the JSON file with processing parameters.
- Returns:
None.
- class Radiomics(**kwargs)[source]
Bases:
object
Organizes the radiomics extraction parameters
- class GLCM(dist_correction: bool | str = False, merge_method: str = 'vol_merge')[source]
Bases:
object
Organizes the GLCM features extraction parameters
- __init__(dist_correction: bool | str = False, merge_method: str = 'vol_merge') None [source]
Constructor of the GLCM class
- Parameters:
dist_correction (Union[bool, str]) – norm for distance weighting, must be “manhattan”, “euclidean” or “chebyshev”. If True the norm for distance weighting is gonna be “euclidean”.
merge_method (str) – merging method which determines how features are calculated. Must be “average”, “slice_merge”, “dir_merge” and “vol_merge”.
- Returns:
None.
- class GLRLM(dist_correction: bool | str = False, merge_method: str = 'vol_merge')[source]
Bases:
object
Organizes the GLRLM features extraction parameters
- __init__(dist_correction: bool | str = False, merge_method: str = 'vol_merge') None [source]
Constructor of the GLRLM class
- Parameters:
dist_correction (Union[bool, str]) – If True the norm for distance weighting is gonna be “euclidean”.
merge_method (str) – merging method which determines how features are calculated. Must be “average”, “slice_merge”, “dir_merge” and “vol_merge”.
- Returns:
None.
- class NGTDM(dist_correction: bool | str | None = None)[source]
Bases:
object
Organizes the NGTDM features extraction parameters
- __init__(dist_correction: bool | str | None = None) None [source]
Constructor of the NGTDM class
- Parameters:
dist_correction (Union[bool, str]) – If True the norm for distance weighting is gonna be “euclidean”.
- Returns:
None.
- __init__(**kwargs) None [source]
Constructor of the Radiomics class.
- __init__() None [source]
Organizes all processing, filtering and features extraction
- class Radiomics(image: Dict | None = None, params: Dict | None = None)[source]
Bases:
object
Organizes all the extracted features.
- __init__(image: Dict | None = None, params: Dict | None = None) None [source]
Constructor of the Radiomics class :param image: Dict of the extracted features. :type image: Dict :param params: Dict of the parameters used in features extraction (roi type, voxels diemension…) :type params: Dict
- Returns:
None
- to_json() Dict [source]
Summarizes the class attributes in a Dict :param None:
- Returns:
Dictionay of radiomics structure (extracted features and extraction params)
- Return type:
Dict
- update_params(params: Dict) None [source]
Updates params attribute from a given Dict :param params: Dict of the parameters used in features extraction (roi type, voxels diemension…) :type params: Dict
- Returns:
None
- __init__(medscan=None) None [source]
Constructor of the MEDscan class
- Parameters:
medscan (MEDscan) – A MEDscan class instance.
- Returns:
None
- class data(orientation: str | None = None, patient_position: str | None = None)[source]
Bases:
object
Organizes all imaging data (volume and ROI).
- volume[source]
Instance of MEDscan.data.volume inner class.
- Type:
object
- ROI[source]
Instance of MEDscan.data.ROI inner class.
- Type:
object
- orientation
Imaging data orientation (axial, sagittal or coronal).
- Type:
str
- patient_position
Patient position specifies the position of the patient relative to the imaging equipment space (HFS, HFP…).
- Type:
str
- class ROI(indexes: Dict | None = None, roi_names: Dict | None = None)[source]
Bases:
object
Organizes all ROI data and information.
- indexes
Dict of the ROI indexes for each ROI name.
- Type:
Dict
- roi_names
Dict of the ROI names.
- Type:
Dict
- nameSet
Dict of the User-defined name for Structure Set for each ROI name.
- Type:
Dict
- nameSetInfo
Dict of the names of the structure sets that define the areas of significance. Either ‘StructureSetName’, ‘StructureSetDescription’, ‘SeriesDescription’ or ‘SeriesInstanceUID’.
- Type:
Dict
- __init__(indexes: Dict | None = None, roi_names: Dict | None = None) None [source]
Constructor of the ROI class.
- Parameters:
indexes (Dict, optional) – Dict of the ROI indexes for each ROI name.
roi_names (Dict, optional) – Dict of the ROI names.
- Returns:
None.
- convert_to_LPS(data: ndarray) ndarray [source]
Converts the given volume to LPS coordinates system. For more details please refer here : https://www.slicer.org/wiki/Coordinate_systems :param data: Volume data in RAS to convert to to LPS :type data: ndarray
- Returns:
n-dimensional of data in LPS.
- Return type:
ndarray
- get_indexes(key)[source]
- get_name_set(key)[source]
- get_name_set_info(key)[source]
- get_roi_from_path(roi_path: Path | str, id: str)[source]
Extracts all ROI data from the given path for the given patient ID and updates all class attributes with the new extracted data.
- Parameters:
roi_path (Union[Path, str]) – Path where the ROI data is stored.
id (str) – ID containing patient ID and the modality type, to identify the right file.
- Returns:
None.
- get_roi_name(key)[source]
- update_indexes(key, indexes)[source]
- update_name_set(key, name_set)[source]
- update_name_set_info(key, nameSetInfo)[source]
- update_roi_name(key, roi_name)[source]
- __init__(orientation: str | None = None, patient_position: str | None = None) None [source]
Constructor of the scan class
- Parameters:
orientation (str, optional) – Imaging data orientation (axial, sagittal or coronal).
patient_position (str, optional) – Patient position specifies the position of the patient relative to the imaging equipment space (HFS, HFP…).
- Returns:
None.
- display(_slice: int | None = None, roi: str | int = 0) None [source]
Displays slices from imaging data with the ROI contour in XY-Plane.
- Parameters:
_slice (int, optional) – Index of the slice you want to plot.
roi (Union[str, int], optional) – ROI name or index. If not specified will use the first ROI.
- Returns:
None.
- display_process(_slice: int | None = None, roi: str | int = 0) None [source]
Displays slices from imaging data with the ROI contour in XY-Plane.
- Parameters:
_slice (int, optional) – Index of the slice you want to plot.
roi (Union[str, int], optional) – ROI name or index. If not specified will use the first ROI.
- Returns:
None.
- get_indexes_by_roi_name(roi_name: str) ndarray [source]
Extract ROI data using the ROI name.
- Parameters:
roi_name (str) – String of the ROI name (A volume can have multiple ROIs).
- Returns:
n-dimensional array of the ROI data.
- Return type:
ndarray
- get_roi_from_indexes(key: int) ndarray [source]
Extracts ROI data using the saved indexes (Indexes of non-null values).
- Parameters:
key (int) – Key of ROI indexes list (A volume can have multiple ROIs).
- Returns:
n-dimensional array of ROI data.
- Return type:
ndarray
- set_ROI(*args)[source]
- set_orientation(orientation)[source]
- set_patient_position(patient_position)[source]
- set_volume(volume)[source]
- class volume(spatialRef: imref3d | None = None, scan_rot: str | None = None, array: ndarray | None = None)[source]
Bases:
object
Organizes all volume data and information related to imaging volume.
- spatialRef
Imaging data orientation (axial, sagittal or coronal).
- Type:
- scan_rot
Array of the rotation applied to the XYZ points of the ROI.
- Type:
ndarray
- array
n-dimensional of the imaging data.
- Type:
ndarray
- __init__(spatialRef: imref3d | None = None, scan_rot: str | None = None, array: ndarray | None = None) None [source]
Organizes all volume data and information.
- Parameters:
spatialRef (imref3d, optional) – Imaging data orientation (axial, sagittal or coronal).
scan_rot (ndarray, optional) – Array of the rotation applied to the XYZ points of the ROI.
array (ndarray, optional) – n-dimensional of the imaging data.
- convert_spatialRef()[source]
converts the spatialRef attribute from RAS to LPS coordinates system. <https://www.slicer.org/wiki/Coordinate_systems>.
- Parameters:
None.
- Returns:
None.
- convert_to_LPS()[source]
Convert Imaging data to LPS (Left-Posterior-Superior) coordinates system. <https://www.slicer.org/wiki/Coordinate_systems>.
- Returns:
None.
- spatialRef_from_nifti(nifti_image_path: Path | str) None [source]
Computes the imref3d spatialRef using a NIFTI file and updates the spatialRef attribute.
- Parameters:
nifti_image_path (str) – String of the NIFTI file path.
- Returns:
None.
- update_array(array)[source]
- update_scan_rot(scan_rot_value)[source]
- update_spatialRef(spatialRef_value)[source]
- update_transScanToModel(transScanToModel_value)[source]
- class volume_process(spatialRef: imref3d | None = None, scan_rot: List | None = None, array: ndarray | None = None, user_string: str = '')[source]
Bases:
object
Organizes all volume data and information.
- spatialRef
Imaging data orientation (axial, sagittal or coronal).
- Type:
- scan_rot
Array of the rotation applied to the XYZ points of the ROI.
- Type:
ndarray
- data
n-dimensional of the imaging data.
- Type:
ndarray
- __init__(spatialRef: imref3d | None = None, scan_rot: List | None = None, array: ndarray | None = None, user_string: str = '') None [source]
Organizes all volume data and information.
- Parameters:
spatialRef (imref3d, optional) – Imaging data orientation (axial, sagittal or coronal).
scan_rot (ndarray, optional) – Array of the rotation applied to the XYZ points of the ROI.
array (ndarray, optional) – n-dimensional of the imaging data.
user_string (str, optional) – string explaining the processed data in the class.
- Returns:
None.
- load(file_name: str, loading_path: Path | str, update: bool = True) None | ndarray [source]
Saves the processed data locally.
- Parameters:
file_name (str) – Name file of the processed data to load.
loading_path (Union[Path, str]) – Path to the processed data to load.
update (bool, optional) – If True, updates the class attrtibutes with loaded data.
- Returns:
None.
- save(name_save: str, path_save: Path | str) None [source]
Saves the processed data locally.
- Parameters:
name_save (str) – Saving name of the processed data.
path_save (Union[Path, str]) – Path to where save the processed data.
- Returns:
None.
- update_processed_data(array: ndarray, user_string: str = '') None [source]
- init_from_nifti(nifti_image_path: Path) None [source]
Initializes the MEDscan class using a NIfTI file.
- Parameters:
nifti_image_path (Path) – NIfTI file path.
- Returns:
None.
- init_ntf_calculation(vol_obj: image_volume_obj) None [source]
Initializes all the computation parameters for non-texture features as well as the results dict.
- Parameters:
vol_obj (image_volume_obj) – Imaging volume.
- Returns:
None.
- init_params(im_param_scan: Dict) None [source]
Initializes the Params class from a dictionary.
- Parameters:
im_param_scan (Dict) – Dictionary of different processing, extraction and filtering params.
- Returns:
None.
- init_tf_calculation(algo: int, gl: int, scale: int) None [source]
Initializes all the computation parameters for the texture-features as well as the results dict.
- Parameters:
algo (int) – Discretisation algorithms index.
gl (int) – gray-level index.
scale (int) – scale-text index.
- Returns:
None.
- save_radiomics(scan_file_name: List, path_save: Path, roi_type: str, roi_type_label: str, patient_num: int | None = None) None [source]
Saves extracted radiomics features in a JSON file.
- Parameters:
scan_file_name (List) – List of scan files.
path_save (Path) – Saving path.
roi_type (str) – Type of the ROI.
roi_type_label (str) – Label of the ROI type.
patient_num (int) – Index of scan.
- Returns:
None.
- update_radiomics(int_vol_hist_features: Dict = {}, morph_features: Dict = {}, loc_int_features: Dict = {}, stats_features: Dict = {}, int_hist_features: Dict = {}, glcm_features: Dict = {}, glrlm_features: Dict = {}, glszm_features: Dict = {}, gldzm_features: Dict = {}, ngtdm_features: Dict = {}, ngldm_features: Dict = {}) None [source]
Updates the results attribute with the extracted features.
- Parameters:
int_vol_hist_features (Dict, optional) – Dictionary of the intensity volume histogram features.
morph_features (Dict, optional) – Dictionary of the morphological features.
loc_int_features (Dict, optional) – Dictionary of the intensity local intensity features.
stats_features (Dict, optional) – Dictionary of the statistical features.
int_hist_features (Dict, optional) – Dictionary of the intensity histogram features.
glcm_features (Dict, optional) – Dictionary of the GLCM features.
glrlm_features (Dict, optional) – Dictionary of the GLRLM features.
glszm_features (Dict, optional) – Dictionary of the GLSZM features.
gldzm_features (Dict, optional) – Dictionary of the GLDZM features.
ngtdm_features (Dict, optional) – Dictionary of the NGTDM features.
ngldm_features (Dict, optional) – Dictionary of the NGLDM features.
- Returns:
None.