Beispiel #1
0
                                        [tract, '_mask.nii.gz'])
            if len(tract_mask) > 1:
                logging.error(
                    'More than one mask file found for tract: {}'.format(
                        tract))
                logging.error('Files found: {}'.format(tract_mask))
                raise RuntimeError('Found more than one mask file!')

            #find_masks() returns a list, even if there is only one file found
            tract_mask = tract_mask[0]
            include_roi_list = eda.find_masks(tract_mask_dir,
                                              [tract, '_include.nii.gz'])

            #Transform mask and spheres into subject space
            subspace_mask = eda.transform_roi(in_image=tract_mask,
                                              add_suffix=sub,
                                              ref=input_dti,
                                              transform=transform_file)
            if subspace_mask is None:
                logging.error(
                    'Transforming mask to subject space failed: {}'.format(
                        in_mask))
                raise RuntimeError(
                    'Transforming mask to subject space failed!')

            #Move the transformed mask to the subject's directory
            shutil.move(subspace_mask, sub_output_dir)
            #Move the aligned mask to the subject's directory

            subspace_include_roi_list = []
            for element in include_roi_list:
                out_name = eda.transform_roi(in_image=element,
Beispiel #2
0
   
       for tract in tract_list:
            try:
                 #Set up mask and sphere file names
                 tract_mask = os.path.join(tract_mask_dir, tract_mask_temp.format(tract=tract))
                 tract_spheres = os.path.join(tract_mask_dir, tract_sphere_temp.format(tract=tract))

                 #Set up subject-space mask and sphere file names
                 sub_tract_mask = os.path.join(sub_output_dir, sub_tract_mask_temp.format(tract=tract, sub=sub))
                 sub_sphere_mask = os.path.join(sub_output_dir, sub_tract_spheres_temp.format(tract=tract, sub=sub))

                 tckgen_out = os.path.join(sub_output_dir, tckgen_out_temp.format(sub=sub, ses=ses, run=run, tract=tract))

                 #Transform mask and spheres into subject space
                 if not os.path.exists(sub_tract_mask):
                   okay = eda.transform_roi(in_image=tract_mask, out_image=sub_tract_mask, ref=ref_image, transform=transform_file)
                   if okay is None:
                        logging.error('Transforming tract mask to subject space failed!')
                        raise RuntimeError('Transforming tract mask to subject space failed!')
                 else:
                   logging.info('Subject tract mask already exists: {}'.format(sub_tract_mask))

                 if not os.path.exists(sub_sphere_mask):
                   okay = eda.transform_roi(in_image=tract_spheres, out_image=sub_sphere_mask, ref=ref_image, transform=transform_file)
                   if okay is None:
                        logging.error('Transforming sphere mask to subject space failed!')
                        raise RuntimeError('Transforming sphere mask to subject space failed!')
                 else:
                  logging.info('Subject sphere mask already exists: {}'.format(sub_sphere_mask))

                 #Run tckgen to generate tracks