Esempio n. 1
0
 def setUp(self):
     self._clean_up()
     self._repository = XnatRepo(project_id=self.project,
                                 server=SERVER,
                                 cache_dir=self.cache_dir)
     self._create_project()
     self.BASE_CLASS.setUp(self)
     local_repository = BasicRepo(self.project_dir)
     tree = local_repository.tree()
     repo = XnatRepo(SERVER, self.project, '/tmp')
     with repo:
         for node in tree:
             for fileset in node.filesets:
                 # Need to forcibly change the repository to be XNAT
                 fileset = copy(fileset)
                 fileset.format = fileset.detect_format(self.REF_FORMATS)
                 fileset._repository = repo
                 fileset.put()
             for field in node.fields:
                 # Need to forcibly change the repository to be XNAT
                 field = copy(field)
                 field._repository = repo
                 field.put()
             for record in node.records:
                 repo.put_record(record)
Esempio n. 2
0
from banana.study.mri.diffusion import NODDIStudy
from arcana.repository.basic import BasicRepo
from banana.file_format import mrtrix_image_format

repository_path = os.path.abspath(os.path.join(
    os.environ['HOME'], 'Data', 'MBI', 'noddi'))
BASE_WORK_PATH = os.path.abspath(os.path.join(
    os.environ['HOME'], 'Data', 'MBI', 'work'))

NODDI_PROJECT = 'pilot'
NODDI_SUBJECT = 'SUBJECT1'
NODDI_SESSION = 'SESSION1'
WORK_PATH = os.path.abspath(os.path.join(BASE_WORK_PATH, 'noddi'))
SESSION_DIR = os.path.join(repository_path, NODDI_PROJECT,
                           NODDI_SUBJECT, NODDI_SESSION)
DATASET_NAME = 'noddi'

shutil.rmtree(WORK_PATH, ignore_errors=True)
os.makedirs(WORK_PATH)
study = NODDIStudy(
    name=DATASET_NAME,
    project_id=NODDI_PROJECT, repository=BasicRepo(repository_path),
    input_scans=[
        InputFilesets('low_b_dw_scan', mrtrix_image_format,
                     'r_l_noddi_b700_30_directions'),
        InputFilesets('high_b_dw_scan', mrtrix_image_format,
                     'r_l_noddi_b2000_60_directions'),
        InputFilesets('forward_rpe', 'r_l_noddi_b0_6', mrtrix_image_format),
        InputFilesets('reverse_rpe', 'l_r_noddi_b0_6', mrtrix_image_format)])
study.noddi_fitting_pipeline().run(work_dir=WORK_PATH)
Esempio n. 3
0
        struct2align=args.struct2align, crop_size=args.cropping_size,
        crop_coordinates=args.cropping_coordinates, mni_reg=args.mni_reg,
        static_len=args.static_pet_len, pct_umap=args.continuos_umap)

    ref, ref_type, t1s, epis, t2s, dwis = mc.create_motion_correction_inputs()

    MotionCorrection, inputs, out_data = create_motion_correction_class(
        'MotionCorrection', ref, ref_type, t1s=t1s, t2s=t2s, dwis=dwis,
        epis=epis, umap_ref=args.umap_ref, umap=args.umap,
        pet_data_dir=args.pet_list_mode_dir, dynamic=args.dynamic,
        pet_recon_dir=args.pet_reconstructed_dir,
        struct2align=args.struct2align)

    sub_id = 'work_sub_dir'
    session_id = 'work_session_dir'
    repository = BasicRepo(args.input_dir+'/work_dir')
    work_dir = os.path.join(args.input_dir, 'motion_detection_cache')
    WORK_PATH = work_dir
    try:
        os.makedirs(WORK_PATH)
    except OSError as e:
        if e.errno != errno.EEXIST:
            raise

    study = MotionCorrection(name='MotionCorrection',
                             processor=SingleProc(WORK_PATH),
                             repository=repository, inputs=inputs,
                             subject_ids=[sub_id], parameters=mc.parameters,
                             visit_ids=[session_id])
    study.data('mean_displacement_plot')
print('Done!')
Esempio n. 4
0
from banana.file_format import mrtrix_image_format

repository_path = os.path.abspath(
    os.path.join(
        os.environ['HOME'],
        'Data',
        'MBI',
        'tbi',
    ))
BASE_WORK_PATH = os.path.abspath(
    os.path.join(os.environ['HOME'], 'Data', 'MBI', 'work'))

WORK_PATH = os.path.abspath(os.path.join(BASE_WORK_PATH, 'tbi_test'))
DATASET_NAME = 'tbi_test'

shutil.rmtree(WORK_PATH, ignore_errors=True)
os.makedirs(WORK_PATH)
study = DwiStudy(name=DATASET_NAME,
                 project_id='2_vs_2.5',
                 repository=BasicRepo(repository_path),
                 input_scans={
                     'dwi_scan': Fileset('R-L_60dir_b2000',
                                         mrtrix_image_format),
                     'forward_rpe': Fileset('R-L_6dir_b0',
                                            mrtrix_image_format),
                     'reverse_rpe': Fileset('L-R_6dir_b0', mrtrix_image_format)
                 })
study.bias_correct_pipeline(bias_method='fsl').run(work_dir=WORK_PATH)
study.fod_pipeline().run(work_dir=WORK_PATH)
study.fa_pipeline().run(work_dir=WORK_PATH)
Esempio n. 5
0
    args = parser.parse_args()
    input_dir = args.input_dir
    dataloader = MoCoDataLoader(input_dir)
    ref, ref_type, t1s, epis, t2s, dwis = dataloader.load()

    MotionDetection, inputs = create_motion_detection_class('MotionDetection',
                                                            ref,
                                                            ref_type,
                                                            t1s=t1s,
                                                            t2s=t2s,
                                                            dwis=dwis,
                                                            epis=epis)

    sub_id = 'work_sub_dir'
    session_id = 'work_session_dir'
    repository = BasicRepo(op.join(input_dir, 'work_dir'))
    work_dir = op.join(input_dir, 'motion_detection_cache')
    WORK_PATH = work_dir
    try:
        os.makedirs(WORK_PATH)
    except OSError as e:
        if e.errno != errno.EEXIST:
            raise

    study = MotionDetection(name='MotionDetection',
                            processor=SingleProc(WORK_PATH),
                            environment=(ModulesEnv() if args.environment
                                         == 'modules' else StaticEnv()),
                            repository=repository,
                            inputs=inputs,
                            subject_ids=[sub_id],
Esempio n. 6
0
 def local_repository(self):
     try:
         return self._local_repository
     except AttributeError:
         self._local_repository = BasicRepo(self.project_dir, depth=2)
         return self._local_repository