deep_folding.brainvisa package¶
Subpackages¶
- deep_folding.brainvisa.utils package
- Submodules
- deep_folding.brainvisa.utils.bbox module
- deep_folding.brainvisa.utils.constants module
- deep_folding.brainvisa.utils.convert_volume_to_bucket module
- deep_folding.brainvisa.utils.dilate_mask module
- deep_folding.brainvisa.utils.distmap module
- deep_folding.brainvisa.utils.folder module
- deep_folding.brainvisa.utils.foldlabel module
- deep_folding.brainvisa.utils.graph module
- deep_folding.brainvisa.utils.logs module
- deep_folding.brainvisa.utils.mask module
- deep_folding.brainvisa.utils.padding module
- deep_folding.brainvisa.utils.parallel module
- deep_folding.brainvisa.utils.quality_checks module
- deep_folding.brainvisa.utils.referentials module
- deep_folding.brainvisa.utils.remove_hull module
- deep_folding.brainvisa.utils.resample module
- deep_folding.brainvisa.utils.save_data module
- deep_folding.brainvisa.utils.skeleton module
- deep_folding.brainvisa.utils.subjects module
- deep_folding.brainvisa.utils.sulcus module
- deep_folding.brainvisa.utils.suppress_files_from_csv module
- deep_folding.brainvisa.utils.write_distance_map module
- Module contents
Submodules¶
deep_folding.brainvisa.benchmark_generation_distmap module¶
Creating abnormal skeleton images
The aim of this script is to generate a benchmark of sulcal abnormalities. Abnormalities are defined as skeletons with one simple surface missing. This simple surface must be completely inside the bounding box of interest and include a minimum number of voxels (in order that the anomaly is big enough to be considered as abnormal).
-
class
deep_folding.brainvisa.benchmark_generation_distmap.Benchmark(b_num, side, ss_size, sulci_list, saving_dir, data_dir='/neurospin/dico/data/bv_databases/human/hcp/hcp', bbox_dir='/neurospin/dico/data/deep_folding/current/bbox/', mask_dir='/neurospin/dico/data/deep_folding/current/mask/1mm/', mask=True, inpainting=False)¶ Bases:
objectGenerates benchmark of altered skeletons
-
delete_ss(sub)¶ Deletes one simple surface
Parameters: sub – int giving the subject
-
generate_foldlabel(sub)¶ Deletes one simple surface :param sub: int giving the subject
-
generate_skeleton(sub)¶ Generates a skeleton from a graph
Parameters: sub – int giving the subject
-
get_simple_surfaces(sub)¶ - Selects simple surfaces of one subject that satisfy following
- conditions: size in [given ss_size min, given ss_size max] and with the right number of voxels included in the mask
Parameters: sub – int giving the subject
-
save_file(sub)¶ Saves the modified skeleton
Parameters: sub – int giving the subject
-
save_lists(abnormality_test, givers, subjects_list)¶ Saves lists of modified subjects
Parameters: - abnormality_test – list of modified subjects
- givers – in case of simple surface addition, list of subjects whose one of the simple surface has been added to another subject
- subjects_list – list of subjects
-
-
deep_folding.brainvisa.benchmark_generation_distmap.generate(b_num, side, ss_size, sulci_list, bench_size=150, subjects_list=None, saving_dir='/neurospin/dico/lguillon/distmap/benchmark/test/', bbox_dir='/neurospin/dico/data/deep_folding/current/bbox/', inpainting=False)¶ Generates a benchmark
Parameters: - b_num – number of the benchmark to create
- side – hemisphere side (either L for left, or R for right hemisphere)
- sulci_list – list of sulcus names
-
deep_folding.brainvisa.benchmark_generation_distmap.get_sub_list(subjects_list)¶ Returns subjects list for which latered skelerons can be created Only right handed HCP subjects
deep_folding.brainvisa.benchmark_pipeline module¶
Full pipeline to create a benchmark of abnormalities.
-
class
deep_folding.brainvisa.benchmark_pipeline.BenchmarkPipe(tgt_dir, sulcus, side, ss_size, mode, bench_size, resampling, bbox_dir, subjects_list)¶ Bases:
objectGenerates benchmark files of a given mode
-
crop_one_file(sub)¶ Normalizes, crops and flips if necessary, one file
Parameters: sub – string giving the subject ID
-
get_sub_list()¶ Get IDs of subjects to normalize, crop
-
launch_pipe()¶ Main API to create benchmark files
-
-
deep_folding.brainvisa.benchmark_pipeline.define_njobs()¶ Returns number of cpus used by main loop
-
deep_folding.brainvisa.benchmark_pipeline.main(argv)¶ Reads argument line and creates benchmark files
Parameters: argv – a list containing command line arguments
-
deep_folding.brainvisa.benchmark_pipeline.parse_args(argv)¶ Function parsing command-line arguments
Parameters: argv – a list containing command line arguments Returns: a list with source directory names, full path sulcus: a string containing the sulcus to analyze number_subjects: number of subjects to analyze Return type: src_dir
deep_folding.brainvisa.compute_bounding_box module¶
The aim of this script is to compute the bounding box for a given sulcus based on a manually labelled dataset
Bounding box corresponds to the biggest box that encompasses the given sulci on all subjects of the manually labelled dataset. It measures the bounding box in the MNI152 space.
-
class
deep_folding.brainvisa.compute_bounding_box.BoundingBoxMax(src_dir='/neurospin/dico/data/bv_databases/human/manually_labeled/pclean/all', path_to_graph='t1mri/t1/default_analysis/folds/3.3/base2018_manual', bbox_dir='test/bbox/1mm', sulcus='F.C.M.ant.', new_sulcus=None, side='R', out_voxel_size=None)¶ Bases:
objectDetermines the maximum Bounding Box around given sulci
It is determined in the MNI ICBM152 nonlinear 2009c asymmetrical template http://www.bic.mni.mcgill.ca/~vfonov/icbm/2009/mni_icbm152_nlin_asym_09b_nifti.zip
-
compute(number_subjects=-1)¶ Main class program to compute the bounding box
Parameters: number_subjects – number_subjects to analyze
-
-
deep_folding.brainvisa.compute_bounding_box.box_ICBM2009c_to_aims_talairach(bbmin_mni152: <built-in function array>, bbmax_mni152: <built-in function array>) → tuple¶ Transform bbox coordinates from MNI152 to AIMS talairach referential
-
deep_folding.brainvisa.compute_bounding_box.compute_bounding_box(src_dir='/neurospin/dico/data/bv_databases/human/manually_labeled/pclean/all', bbox_dir='test/bbox/1mm', path_to_graph='t1mri/t1/default_analysis/folds/3.3/base2018_manual', sulcus='F.C.M.ant.', new_sulcus=None, side='R', number_subjects=-1, out_voxel_size=None)¶ Main program computing the box encompassing the sulcus in all subjects
The programm loops over all subjects and computes in MNI space the voxel coordinates of the box encompassing the sulci for all subjects
Parameters: - src_dir – list of strings -> directories of the supervised databases
- bbox_dir – string giving target bbox directory path
- path_to_graph – string giving relative path to manually labelled graph
- side – hemisphere side (either ‘L’ for left, or ‘R’ for right)
- sulcus – string giving the sulcus to analyze
- new_sulcus – string giving a new sulcus name (optional)
- number_subjects – integer giving the number of subjects to analyze, by default it is set to _ALL_SUBJECTS (-1)
- out_voxel_size – float giving voxel size in mm
Returns: tuple (bbmin_vox, bbmax_vox)
-
deep_folding.brainvisa.compute_bounding_box.compute_box_voxel(bbmin_mni152, bbmax_mni152, voxel_size_out)¶ Returns the coordinates of the box as voxels
Coordinates of the box in voxels are determined in the MNI referential
Parameters: - bbmin_mni152 – numpy array with coordinates of the upper right corner of the box (MNI152 space)
- bbmax_mni152 – numpy array with coordinates of the lower left corner of the box (MNI152 space)
- voxel_size – voxel size (in MNI referential or HCP normalized SPM space)
Returns: - tuple (bbmin_vox, bbmax_vox) with
- bbmin_vox: numpy array with coordinates of the upper right corner
of the box (voxels in MNI space);
- bbmax_vox: numpy array with coordinates of the lower left corner
of the box (voxels in MNI space)
-
deep_folding.brainvisa.compute_bounding_box.get_bounding_boxes(subjects, sulcus)¶ get bounding boxes of the chosen sulcus for all subjects.
Function that outputs bounding box for the listed sulci on a manually labeled dataset. Bounding box corresponds to the biggest box encountered in the manually labeled subjects in the MNI1 152 space. The bounding box is the smallest rectangular box that encompasses the sulcus.
Parameters: - subjects – list containing all subjects to be analyzed
- sulcus – str -> sulcus to be analyzed
Returns: - list_bbmin: list containing the upper right vertex of the box
in the MNI 152 space;
- list_bbmax: list containing the lower left vertex of the box
in the MNI 152 space
Return type: tuple (list_bbmin, list_bbmax) with
-
deep_folding.brainvisa.compute_bounding_box.get_one_bounding_box(graph_filename, sulcus)¶ get bounding box of the chosen sulcus for one data graph in MNI 152
Function that outputs the bounding box for the listed sulci for this datagraph. The bounding box is the smallest rectangular box that encompasses the chosen sulcus. It is given in the MNI 152 referential.
Parameters: graph_filename – string being the name of graph file .arg to analyze: for example: ‘Lammon_base2018_manual.arg’ Returns: - numpy array giving the upper right vertex coordinates
- of the box in the MNI 152 referential
- bbox_max: numpy array fiving the lower left vertex coordinates
- of the box in the MNI 152 referential
Return type: bbox_min
-
deep_folding.brainvisa.compute_bounding_box.parse_args(argv: list) → dict¶ Function parsing command-line arguments
Parameters: argv – a list containing command line arguments Returns: a dictionary with all arugments as keys Return type: params
deep_folding.brainvisa.compute_mask module¶
The aim of this script is to output bounding box and mask for a given sulcus based on a manually labelled dataset
Bounding box corresponds to the biggest box that encompasses the given sulci on all subjects of the manually labelled dataset. It measures the bounding box in the MNI152 space.
-
class
deep_folding.brainvisa.compute_mask.MaskAroundSulcus(src_dir='/neurospin/dico/data/bv_databases/human/manually_labeled/pclean/all', path_to_graph='t1mri/t1/default_analysis/folds/3.3/base2018_manual', mask_dir='test/mask/1mm', sulcus='F.C.M.ant.', new_sulcus=None, side='R', out_voxel_size=None)¶ Bases:
objectDetermines the maximum Bounding Box around given sulci
It is determined in the MNI ICBM152 nonlinear 2009c asymmetrical template http://www.bic.mni.mcgill.ca/~vfonov/icbm/2009/mni_icbm152_nlin_asym_09b_nifti.zip
-
compute(number_subjects=-1)¶ Main class program to compute the bounding box
Parameters: number_subjects – number_subjects to analyze
-
-
deep_folding.brainvisa.compute_mask.compute_mask(src_dir='/neurospin/dico/data/bv_databases/human/manually_labeled/pclean/all', mask_dir='test/mask/1mm', path_to_graph='t1mri/t1/default_analysis/folds/3.3/base2018_manual', sulcus='F.C.M.ant.', new_sulcus=None, side='R', number_subjects=-1, out_voxel_size=None)¶ Main program computing the box encompassing the sulcus in all subjects
The programm loops over all subjects and computes in MNI space the voxel coordinates of the box encompassing the sulci for all subjects
Parameters: - src_dir – list of strings -> directories of the supervised databases
- mask_dir – string giving target mask directory path
- path_to_graph – string giving relative path to manually labelled graph
- side – hemisphere side (either ‘L’ for left, or ‘R’ for right)
- sulcus – string giving the sulcus to analyze
- new_sulcus – string giving a new sulcus name (optional)
- number_subjects – integer giving the number of subjects to analyze, by default it is set to _ALL_SUBJECTS (-1)
- out_voxel_size – float giving voxel size
Returns: aims volume containing the mask
-
deep_folding.brainvisa.compute_mask.increment_mask(subjects: list, mask: <function Volume at 0x7f32bb7240d0>, sulcus: str, voxel_size_out: tuple, sample_dir: str)¶ Increments mask for the chosen sulcus for all subjects
Parameters: subjects – list containing all subjects to be analyzed
-
deep_folding.brainvisa.compute_mask.increment_one_mask(graph_filename, mask, sulcus, voxel_size_out)¶ Increments self.mask of 1 where there is the sulcus
Parameters: graph_filename – string being the name of graph file .arg to analyze: for example: ‘Lammon_base2018_manual.arg’
-
deep_folding.brainvisa.compute_mask.initialize_mask(out_voxel_size: tuple) → <function Volume at 0x7f32bb7240d0>¶ Creates aims volume in MNI ICBM152 nonlinear 2009c asymmetrical template http://www.bic.mni.mcgill.ca/~vfonov/icbm/2009/mni_icbm152_nlin_asym_09b_nifti.zip
Parameters: output_voxel_size – tuple Output voxel size (default: None, no resampling) Returns: - volume (aims.Volume_S16) filled with 0 in MNI2009 referential
- and with requested voxel_size
Return type: mask
-
deep_folding.brainvisa.compute_mask.parse_args(argv: list) → dict¶ Function parsing command-line arguments
Parameters: argv – a list containing command line arguments Returns: a dictionary with all arugments as keys Return type: params
-
deep_folding.brainvisa.compute_mask.write_mask(mask: <function Volume at 0x7f32bb7240d0>, mask_file: str)¶ Writes mask on mask file
deep_folding.brainvisa.display_reconstructions module¶
The aim of this script is to display saved model outputs with Anatomist. Model outputs are stored as numpy arrays.
-
deep_folding.brainvisa.display_reconstructions.array_to_ana(ana_a, img, sub_id, phase, status, bucket, vs)¶ Transforms output tensor into volume readable by Anatomist and defines name of the volume displayed in Anatomist window. Returns volume displayable by Anatomist either on the skeleton mode, that can be viewed in consecutive 2D slices, or on 3D buckets.
-
deep_folding.brainvisa.display_reconstructions.main()¶ In the Anatomist window, for each model output, corresponding input will also be displayed at its left side. Number of columns and view (Sagittal, coronal, frontal) can be specified. (It’s better to choose an even number for number of columns to display)
deep_folding.brainvisa.generate_ICBM2009c_transforms module¶
Write transform files to ICBM 2009c from graph files
Typical usage¶
You can use this program by first entering in the brainvisa environment (here brainvisa 5.0.0 installed with singurity) and launching the script from the terminal: >>> bv bash >>> python generate_ICBM2009c_transforms.py
-
class
deep_folding.brainvisa.generate_ICBM2009c_transforms.GraphGenerateTransform(src_dir, transform_dir, side, parallel, path_to_graph, bids)¶ Bases:
objectClass to convert all graphs from a folder into skeletons
It contains all information to scan a dataset for graphs and writes skeletons and foldlabels into target directory
-
compute(number_subjects)¶ Loops over subjects to generate transforms to ICBM2009c from graphs.
-
generate_one_transform(subject: str)¶ Generates and writes ICBM2009c transform for one subject.
-
get_transform_filename(subject, graph_file)¶
-
-
deep_folding.brainvisa.generate_ICBM2009c_transforms.generate_ICBM2009c_transforms(src_dir='/neurospin/dico/data/bv_databases/human/not_labeled/hcp/hcp', transform_dir='test/datasets/hcp/transforms', path_to_graph='t1mri/BL/default_analysis/folds/3.1', side='R', bids=False, parallel=False, number_subjects=-1)¶ Generates skeletons from graphs
-
deep_folding.brainvisa.generate_ICBM2009c_transforms.parse_args(argv)¶ Parses command-line arguments
Parameters: argv – a list containing command line arguments Returns: args
deep_folding.brainvisa.generate_crops module¶
Creating npy file from T1 MRI datas The aim of this script is to create dataset of cropped skeletons from MRIs saved in a .npy file. We read resampled skeleton files Several steps are required: crop and .npy generation
You can use this program by first entering in the brainvisa environment (here brainvisa 5.0.0 installed with singurity) and launching the script from the terminal: >>> bv bash >>> python3 generate_crops.py Alternatively, you can launch the script in the interactive terminal ipython: >>> %run generate_crops.py
-
class
deep_folding.brainvisa.generate_crops.CropGenerator(src_dir='test/datasets/hcp/skeletons/1mm', crop_dir='test/datasets/hcp/crops/CINGULATE/mask/1mm', bbox_dir='test/bbox/1mm', mask_dir='test/mask/1mm', dilation=5.0, threshold=0.0, list_sulci='F.C.M.ant.', side='R', cropping_type='mask', combine_type=False, parallel=False, no_mask=False)¶ Bases:
objectGenerates cropped skeleton files and corresponding npy file
-
compute(number_subjects=-1)¶ Main API to create numpy files The programm loops over all subjects from the input (source) directory. :param number_subjects: integer giving the number of subjects to analyze,
by default it is set to _ALL_SUBJECTS (-1).
-
compute_bounding_box_or_mask(number_subjects)¶ Computes bounding box or mask :param number_subjects: integer giving the number of subjects to analyze,
by default it is set to _ALL_SUBJECTS (-1).
-
crop_files(number_subjects=-1)¶ Crop nii files The programm loops over all subjects from the input (source) directory. :param number_subjects: integer giving the number of subjects to analyze,
by default it is set to _ALL_SUBJECTS (-1).
-
crop_one_file(subject_id)¶ Crops one file :param subject_id: string giving the subject ID
-
-
class
deep_folding.brainvisa.generate_crops.DistMapCropGenerator(src_dir='test/datasets/hcp/skeletons/1mm', crop_dir='test/datasets/hcp/crops/CINGULATE/mask/1mm', bbox_dir='test/bbox/1mm', mask_dir='test/mask/1mm', list_sulci='F.C.M.ant.', side='R', cropping_type='mask', combine_type=False, parallel=False, no_mask=False)¶ Bases:
deep_folding.brainvisa.generate_crops.CropGeneratorGenerates cropped skeleton files and corresponding npy file
-
class
deep_folding.brainvisa.generate_crops.FoldLabelCropGenerator(src_dir='test/datasets/hcp/skeletons/1mm', crop_dir='test/datasets/hcp/crops/CINGULATE/mask/1mm', bbox_dir='test/bbox/1mm', mask_dir='test/mask/1mm', list_sulci='F.C.M.ant.', side='R', cropping_type='mask', combine_type=False, parallel=False, no_mask=False)¶ Bases:
deep_folding.brainvisa.generate_crops.CropGeneratorGenerates cropped skeleton files and corresponding npy file
-
class
deep_folding.brainvisa.generate_crops.SkeletonCropGenerator(src_dir='test/datasets/hcp/skeletons/1mm', crop_dir='test/datasets/hcp/crops/CINGULATE/mask/1mm', bbox_dir='test/bbox/1mm', mask_dir='test/mask/1mm', list_sulci='F.C.M.ant.', side='R', cropping_type='mask', combine_type=False, parallel=False, no_mask=False)¶ Bases:
deep_folding.brainvisa.generate_crops.CropGeneratorGenerates cropped skeleton files and corresponding npy file
-
deep_folding.brainvisa.generate_crops.crop_bbox(file_src: str, file_cropped: str, bbmin: <built-in function array>, bbmax: <built-in function array>)¶ Crops according to bounding box
-
deep_folding.brainvisa.generate_crops.crop_mask(file_src, file_cropped, mask, bbmin, bbmax, side, no_mask=False)¶ Crops according to mask
-
deep_folding.brainvisa.generate_crops.filter_mask(mask: <function Volume at 0x7f32bb7240d0>)¶ Smooths the mask with Gaussian Filter
-
deep_folding.brainvisa.generate_crops.generate_crops(src_dir='test/datasets/hcp/skeletons/1mm', input_type='skeleton', crop_dir='test/datasets/hcp/crops/CINGULATE/mask/1mm', bbox_dir='test/bbox/1mm', mask_dir='test/mask/1mm', side='R', list_sulci='F.C.M.ant.', number_subjects=-1, cropping_type='mask', combine_type=False, parallel=False, no_mask=True)¶
-
deep_folding.brainvisa.generate_crops.parse_args(argv)¶ Function parsing command-line arguments :param argv: a list containing command line arguments
Returns: dictionary with keys: src_dir, tgt_dir, nb_subjects, list_sulci Return type: params
deep_folding.brainvisa.generate_distmaps module¶
Write distance maps from skeleton files
Note: generation of distance maps should be performed for each resolution
Typical usage¶
You can use this program by first entering in the brainvisa environment (here brainvisa 5.0.0 installed with singurity) and launching the script from the terminal: >>> bv bash >>> python generate_distmap.py
-
class
deep_folding.brainvisa.generate_distmaps.SkelConvert2DistMap(src_dir, distmaps_dir, side, parallel, resampled_skel=False)¶ Bases:
objectClass to convert all skeletons from a folder into distance maps
It contains all information to scan a dataset for skeletons and writes distance maps into target directory
-
compute(number_subjects)¶ Loops over subjects and converts graphs into distmaps.
-
generate_one_distmap(subject: str)¶ Generates and writes distmap for one subject.
-
-
deep_folding.brainvisa.generate_distmaps.generate_distmaps(src_dir='test/datasets/hcp/skeletons/raw', distmaps_dir='test/datasets/hcp/distmaps/raw', side='R', parallel=False, resampled_skel=True, number_subjects=-1)¶ Generates distmaps from skeletons
-
deep_folding.brainvisa.generate_distmaps.parse_args(argv)¶ Parses command-line arguments
Parameters: argv – a list containing command line arguments Returns: args
deep_folding.brainvisa.generate_foldlabels module¶
Write foldlabels from graph files
Typical usage¶
You can use this program by first entering in the brainvisa environment (here brainvisa 5.0.0 installed with singurity) and launching the script from the terminal: >>> bv bash >>> python generate_foldlabels.py
-
class
deep_folding.brainvisa.generate_foldlabels.GraphConvert2FoldLabel(src_dir, foldlabel_dir, side, junction, parallel, path_to_graph, bids, qc_path)¶ Bases:
objectClass to convert graph into foldlabel files
It contains all information to scan a dataset for graphs and writes foldlabels into target directory
-
compute(number_subjects)¶ Loops over subjects and converts graphs into skeletons.
-
generate_one_foldlabel(subject: str)¶ Generates and writes skeleton for one subject.
-
get_foldlabel_filename(subject, graph_file)¶
-
-
deep_folding.brainvisa.generate_foldlabels.generate_foldlabels(src_dir='/neurospin/dico/data/bv_databases/human/not_labeled/hcp/hcp', foldlabel_dir='test/datasets/hcp/foldlabels/raw', path_to_graph='t1mri/BL/default_analysis/folds/3.1', side='R', junction='thin', bids=False, parallel=False, number_subjects=-1, qc_path='')¶ Generates foldlabels from graphs
-
deep_folding.brainvisa.generate_foldlabels.parse_args(argv)¶ Parses command-line arguments
Parameters: argv – a list containing command line arguments Returns: args
deep_folding.brainvisa.generate_skeletons module¶
Write skeletons from graph files
Typical usage¶
You can use this program by first entering in the brainvisa environment (here brainvisa 5.0.0 installed with singurity) and launching the script from the terminal: >>> bv bash >>> python generate_skeletons.py
-
class
deep_folding.brainvisa.generate_skeletons.GraphConvert2Skeleton(src_dir, skeleton_dir, side, junction, parallel, path_to_graph, bids, qc_path)¶ Bases:
objectClass to convert all graphs from a folder into skeletons
It contains all information to scan a dataset for graphs and writes skeletons into target directory
-
compute(number_subjects)¶ Loops over subjects and converts graphs into skeletons.
-
generate_one_skeleton(subject: str)¶ Generates and writes skeleton for one subject.
-
get_skeleton_filename(subject, graph_file)¶
-
-
deep_folding.brainvisa.generate_skeletons.generate_skeletons(src_dir='/neurospin/dico/data/bv_databases/human/not_labeled/hcp/hcp', skeleton_dir='test/datasets/hcp/skeletons/raw', path_to_graph='t1mri/BL/default_analysis/folds/3.1', side='R', junction='thin', bids=False, parallel=False, number_subjects=-1, qc_path='')¶ Generates skeletons from graphs
-
deep_folding.brainvisa.generate_skeletons.parse_args(argv)¶ Parses command-line arguments
Parameters: argv – a list containing command line arguments Returns: args
deep_folding.brainvisa.mask_qc module¶
Quality check of generated masks
-
deep_folding.brainvisa.mask_qc.check(side='R', sulcus='S.C.', out_voxel_size=(2, 2, 2), nb_subjects=1)¶
-
deep_folding.brainvisa.mask_qc.main(argv)¶ Reads argument line and creates cropped files and pickle file
Parameters: argv – a list containing command line arguments
-
deep_folding.brainvisa.mask_qc.parse_args(argv)¶ Function parsing command-line arguments
Parameters: argv – a list containing command line arguments Returns: dictionary with keys: src_dir, tgt_dir, nb_subjects, list_sulci Return type: params
deep_folding.brainvisa.pipeline module¶
-
deep_folding.brainvisa.pipeline.get_sulci_list(region_name, side, json_path='/neurospin/dico/data/deep_folding/current/sulci_regions_overlap.json')¶
-
deep_folding.brainvisa.pipeline.is_directory_empty(path)¶
-
deep_folding.brainvisa.pipeline.is_step_to_be_computed(path, log_string, save_behavior='best')¶
-
deep_folding.brainvisa.pipeline.parse_args(argv: list) → dict¶ Function parsing command-line arguments
Parameters: argv – a list containing command line arguments Returns: a dictionary with all arugments as keys Return type: params
-
deep_folding.brainvisa.pipeline.print_info(step, description)¶
deep_folding.brainvisa.remove_ventricle module¶
Remove ventricle from a skeleton through the automatic labelled graph by Morphologist. Be careful : the script will not work if there are ‘_’ in subject ids (for database in BIDS format).
-
class
deep_folding.brainvisa.remove_ventricle.RemoveVentricleFromSkeleton(skeleton_dir, output_dir, morpho_dir, path_to_graph, skeleton_filename, output_filename, side, bids, parallel)¶ Bases:
objectClass to remove ventricle from skeleton files through the automatic labelling graph computed by Morphologist. The default automatic labelling session is : deepcnn_session_auto.
It contains all the information to get labelled graphs from skeleton filenames and to write new sketletons without ventricle in the target directory.
-
compute(number_subjects)¶ Loops over subjects and remove ventricle from skeletons.
-
get_labelled_graph(subject: str)¶ Find the labelled graph in the morphologist database from the skeleton filename.
-
remove_ventricle_from_one_subject(subject: str)¶ Removes ventricle and writes new skeleton for one subject.
-
-
deep_folding.brainvisa.remove_ventricle.parse_args(argv)¶ Parses command-line arguments :param argv: a list containing command line arguments
Returns: args
-
deep_folding.brainvisa.remove_ventricle.remove_ventricle(skeleton_dir='test/datasets/hcp/skeletons/raw', output_dir='test/datasets/hcp/skeletons/raw/without_ventricle', morpho_dir='/neurospin/dico/data/bv_databases/human/not_labeled/hcp/hcp', path_to_graph='t1mri/BL/default_analysis/folds/3.1', skeleton_filename='skeleton_generated', output_filename='skeleton_generated_without_ventricle', side='R', bids=False, parallel=False, number_subjects=-1)¶ Remove ventricle from a skeleton through the automatic labelled graph by Morphologist
-
deep_folding.brainvisa.remove_ventricle.remove_ventricle_from_one_skeleton(skeleton_file, labelled_graph_file)¶
deep_folding.brainvisa.resample_files module¶
Resample skeletons
The aim of this script is to resample skeletons, foldlabels and distmaps.
You can use this program by first entering in the brainvisa environment (here brainvisa 5.0.0 installed with singurity) and launching the script from the terminal: >>> bv bash >>> python resample_files.py
Alternatively, you can launch the script in the interactive terminal ipython: >>> %run resample_files.py
-
class
deep_folding.brainvisa.resample_files.DistMapResampler(src_dir, resampled_dir, transform_dir, side, out_voxel_size, parallel, src_filename, output_filename)¶ Bases:
deep_folding.brainvisa.resample_files.FileResamplerResamples all files from source directories
-
static
resample_one_subject(src_file: str, out_voxel_size: float, transform_file: str, resampled_file: str)¶
-
static
-
class
deep_folding.brainvisa.resample_files.FileResampler(src_dir, resampled_dir, transform_dir, side, out_voxel_size, parallel)¶ Bases:
objectResamples all files from source directories
Parent class from which derive SkeletonResampler, FoldLabelResampler,…
-
compute(number_subjects=-1)¶ Loops over nii files
The programm loops over all subjects from the input (source) directory.
Parameters: number_subjects – integer giving the number of subjects to analyze, by default it is set to _ALL_SUBJECTS (-1).
-
static
resample_one_subject(src_file: str, out_voxel_size: float, transform_file: str, resampled_file=None)¶ Resamples skeleton
This static method is called by resample_one_subject_wrapper from parent class FileResampler
-
resample_one_subject_wrapper(subject_id)¶ Resamples one file
Parameters: subject_id – string giving the subject ID
-
-
class
deep_folding.brainvisa.resample_files.FoldLabelResampler(src_dir, resampled_dir, transform_dir, side, out_voxel_size, parallel, src_filename, output_filename)¶ Bases:
deep_folding.brainvisa.resample_files.FileResamplerResamples all files from source directories
-
static
resample_one_subject(src_file: str, out_voxel_size: float, transform_file: str, resampled_file=None)¶
-
static
-
class
deep_folding.brainvisa.resample_files.SkeletonResampler(src_dir, resampled_dir, transform_dir, side, out_voxel_size, parallel, src_filename, output_filename)¶ Bases:
deep_folding.brainvisa.resample_files.FileResamplerResamples all skeletons from source directories
-
static
resample_one_subject(src_file: str, out_voxel_size: float, transform_file: str, resampled_file=None)¶ Resamples skeleton
This static method is called by resample_one_subject_wrapper from parent class FileResampler
-
static
-
deep_folding.brainvisa.resample_files.parse_args(argv)¶ Function parsing command-line arguments
Parameters: argv – a list containing command line arguments Returns: dictionary with keys: src_dir, tgt_dir, nb_subjects, list_sulci Return type: params
-
deep_folding.brainvisa.resample_files.resample_files(src_dir='test/datasets/hcp/skeletons/raw', input_type='skeleton', resampled_dir='test/datasets/hcp/skeletons/1mm', transform_dir='test/datasets/hcp/transforms', side='R', out_voxel_size=1.0, parallel=False, number_subjects=-1, src_filename='skeleton_generated_', output_filename='resampled_skeleton_')¶
-
deep_folding.brainvisa.resample_files.resample_one_distmap(input_image, resampled_dir, out_voxel_size, transformation)¶ Resamples one distmap file
Parameters: - input_image (either string or aims.Volume) – either path to distmap or distmap aims Volume
- out_voxel_size (tuple) – Output voxel size (default: None, no resampling)
- transformation (string or aims.Volume) – either path to transformation file or transformation itself
Returns: Save transformed or resampled volume
-
deep_folding.brainvisa.resample_files.resample_one_foldlabel(input_image, out_voxel_size, transformation)¶ Resamples one foldlabel file
Parameters: - input_image (either string or aims.Volume) – either path to foldlabel or foldlabel aims Volume
- out_voxel_size (tuple) – Output voxel size (default: None, no resampling)
- transformation (string or aims.Volume) – either path to transformation file or transformation itself
Returns: - aims.Volume
Transformed or resampled volume
Return type: resampled
-
deep_folding.brainvisa.resample_files.resample_one_skeleton(input_image, out_voxel_size, transformation)¶ Resamples one skeleton file
Parameters: - input_image (either string or aims.Volume) – either path to skeleton or skeleton aims Volume
- out_voxel_size (tuple) – Output voxel size (default: None, no resampling)
- transformation (string or aims.Volume) – either path to transformation file or transformation itself
Returns: - aims.Volume
Transformed or resampled volume
Return type: resampled