Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mdiazmel committed Jun 20, 2020
2 parents 7f5f520 + cea780e commit 06fdbc5
Show file tree
Hide file tree
Showing 40 changed files with 1,809 additions and 1,641 deletions.
25 changes: 22 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ pipeline {
environment {
PATH = "$HOME/miniconda/bin:$PATH"
}
when { changeset "environment.yml" }
when {
changeset "requirements.txt"
}
steps {
echo 'Building Conda environment... ${BRANCH_NAME}'
sh 'ls'
Expand All @@ -26,7 +28,9 @@ pipeline {
environment {
PATH = "$HOME/miniconda3/bin:$PATH"
}
when { changeset "environment.yml" }
when {
changeset "requirements.txt"
}
steps {
echo 'Building Conda environment...' + 'env.BRANCH_NAME'
sh 'ls'
Expand Down Expand Up @@ -114,6 +118,7 @@ pipeline {
cd test
ln -s /mnt/data/ci/data_ci_linux ./data
taskset -c 0-21 pytest \
--junitxml=./test-reports/instantation_linux.xml \
--verbose \
--working_directory=$WORK_DIR_LINUX \
--disable-warnings \
Expand All @@ -124,6 +129,11 @@ pipeline {
conda deactivate
'''
}
post {
always {
junit 'test/test-reports/*.xml'
}
}
}
stage('Instantiate Mac') {
agent { label 'macos' }
Expand All @@ -143,11 +153,20 @@ pipeline {
module load clinica.all
cd test
ln -s /Volumes/data/data_ci ./data
pytest --verbose --disable-warnings -k 'test_instantiate'
pytest \
--verbose \
--junitxml=./test-reports/instantation_mac.xml \
--disable-warnings \
-k 'test_instantiate'
module purge
conda deactivate
'''
}
post {
always {
junit 'test/test-reports/*.xml'
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clinica/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.4
0.3.5
2 changes: 2 additions & 0 deletions clinica/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def execute():
from clinica.pipelines.t1_volume_existing_template.t1_volume_existing_template_cli import T1VolumeExistingTemplateCLI
from clinica.pipelines.t1_volume_parcellation.t1_volume_parcellation_cli import T1VolumeParcellationCLI
from clinica.pipelines.t1_linear.t1_linear_cli import T1LinearCLI
from clinica.pipelines.deeplearning_prepare_data.deeplearning_prepare_data_cli import DeepLearningPrepareDataCLI
from clinica.pipelines.dwi_preprocessing_using_phasediff_fieldmap.dwi_preprocessing_using_phasediff_fieldmap_cli import DwiPreprocessingUsingPhaseDiffFieldmapCli
from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_cli import DwiPreprocessingUsingT1Cli
from clinica.pipelines.dwi_dti.dwi_dti_cli import DwiDtiCli
Expand Down Expand Up @@ -230,6 +231,7 @@ def execute():
PETVolumeCLI(),
PetSurfaceCLI(),
# PetSurfaceLongitudinalCLI(),
DeepLearningPrepareDataCLI(),
SpatialSVMCLI(),
StatisticsSurfaceCLI(),
StatisticsVolumeCLI(),
Expand Down
1 change: 0 additions & 1 deletion clinica/iotools/converters/nifd_to_bids/nifd_to_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

def convert_images(path_to_dataset, bids_dir, path_to_clinical):
# Conversion of the entire dataset in BIDS

'''Scans available files in the path_to_dataset,
identifies the patients that have images described by the json file,
converts the image with the highest quality for each category'''
Expand Down
1 change: 0 additions & 1 deletion clinica/iotools/utils/data_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ def create_subs_sess_list(input_dir, output_dir,


def center_nifti_origin(input_image, output_image):

"""
Put the origin of the coordinate system at the center of the image
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# coding: utf8


import clinica.engine as ce
from colorama import Fore

class DeepLearningPrepareDataCLI(ce.CmdParser):

def define_name(self):
"""Define the sub-command name to run this pipeline."""
self._name = 'deeplearning-prepare-data'

def define_description(self):
"""Define a description of this pipeline."""
self._description = ('Prepare data generated Clinica for PyTorch with Tensor extraction:\n'
'http://clinica.run/doc/Pipelines/DeepLearning_PrepareData/')

def define_options(self):
"""Define the sub-command arguments."""
from clinica.engine.cmdparser import PIPELINE_CATEGORIES

# Clinica compulsory arguments (e.g. BIDS, CAPS, group_id...)
# Most of the time, you will want to read your pipeline inputs into
# a BIDS and/or CAPS directory. If your pipeline does not require BIDS input,
# simply remove the two lines involving the BIDS directory.
clinica_comp = self._args.add_argument_group(PIPELINE_CATEGORIES['CLINICA_COMPULSORY'])
clinica_comp.add_argument("caps_directory",
help='Path to the CAPS directory.')
clinica_comp.add_argument("extract_method",
help='''Format of the extracted features. Three options:
'image' to convert to PyTorch tensor the complete 3D image,
'patch' to extract 3D volumetric patches and
'slice' to extract 2D slices from the image.
By default the features are extracted from the cropped image.''',
choices=['image', 'slice', 'patch'], default='image'
)

optional = self._args.add_argument_group(PIPELINE_CATEGORIES['OPTIONAL'])
optional.add_argument('-uui', '--use_uncropped_image',
help='''Use the uncropped image instead of the
cropped image generated by t1-linear.''',
default=False, action="store_true"
)

optional_patch = self._args.add_argument_group(
"%sPipeline options if you chose ‘patch’ extraction%s" % (Fore.BLUE, Fore.RESET)
)
optional_patch.add_argument(
'-ps', '--patch_size',
help='''Patch size (default: --patch_size 50).''',
type=int, default=50
)
optional_patch.add_argument(
'-ss', '--stride_size',
help='''Stride size (default: --stride_size 50).''',
type=int, default=50
)

optional_slice = self._args.add_argument_group(
"%sPipeline options if you chose ‘slice’ extraction%s" % (Fore.BLUE, Fore.RESET)
)
optional_slice.add_argument(
'-sd', '--slice_direction',
help='''Slice direction. Three options:
'0' -> Sagittal plane,
'1' -> Coronal plane or
'2' -> Axial plane
(default: sagittal plane i.e. --slice_direction 0)''',
type=int, default=0
)
optional_slice.add_argument(
'-sm', '--slice_mode',
help='''Slice mode. Two options: 'rgb' to save the slice in
three identical channels, ‘single’ to save the slice in a
single channel (default: --slice_mode rgb).''',
choices=['rgb', 'single'], default='rgb'
)

# Clinica standard arguments (e.g. --n_procs)
self.add_clinica_standard_arguments()

def run_command(self, args):
"""Run the pipeline with defined args."""
from networkx import Graph
from .deeplearning_prepare_data_pipeline import DeepLearningPrepareData
from clinica.utils.ux import print_end_pipeline, print_crash_files_and_exit

parameters = {
# Add your own pipeline parameters here to use them inside your
# pipeline. See the file `deeplearning_prepare_data_pipeline.py` to
# see an example of use.
'extract_method': args.extract_method,
'patch_size': args.patch_size,
'stride_size': args.stride_size,
'slice_direction': args.slice_direction,
'slice_mode': args.slice_mode,
'use_uncropped_image': args.use_uncropped_image,
}

pipeline = DeepLearningPrepareData(
caps_directory=self.absolute_path(args.caps_directory),
tsv_file=self.absolute_path(args.subjects_sessions_tsv),
base_dir=self.absolute_path(args.working_directory),
parameters=parameters,
name=self.name
)

if args.n_procs:
exec_pipeline = pipeline.run(plugin='MultiProc',
plugin_args={'n_procs': args.n_procs})
else:
exec_pipeline = pipeline.run()

if isinstance(exec_pipeline, Graph):
print_end_pipeline(self.name, pipeline.base_dir, pipeline.base_dir_was_specified)
else:
print_crash_files_and_exit(args.logname, pipeline.base_dir)
Loading

0 comments on commit 06fdbc5

Please sign in to comment.