Exemplo n.º 1
0
    def run(self, args, extra_args):
        batch_profile = batch_profile_factory(
            args.batch_profile, os.path.realpath(args.data_folder))

        subjects_selection = None
        if args.subjects_index or args.subjects_id:
            indices = args.subjects_index if args.subjects_index else []
            subject_ids = args.subjects_id if args.subjects_id else []

            subjects_selection = SelectedSubjects(indices=indices,
                                                  subject_ids=subject_ids)

        tmp_results_dir = args.tmp_results_dir
        for match, to_set in [('true', True), ('false', False),
                              ('none', None)]:
            if tmp_results_dir.lower() == match:
                tmp_results_dir = to_set
                break

        mdt.batch_fit(os.path.realpath(args.data_folder),
                      args.models_to_fit,
                      output_folder=args.output_folder,
                      subjects_selection=subjects_selection,
                      batch_profile=batch_profile,
                      recalculate=args.recalculate,
                      cl_device_ind=args.cl_device_ind,
                      double_precision=args.double_precision,
                      dry_run=args.dry_run,
                      tmp_results_dir=tmp_results_dir,
                      use_gradient_deviations=args.use_gradient_deviations)
                    subjects.append(
                        SimpleSubjectInfo(data_folder, subject_pjoin(),
                                          directory + '_' + resolution,
                                          dwi_fname, protocol_loader,
                                          mask_fname))

        return subjects

    def __str__(self):
        return 'Rheinland'


'''batch fit all subjects'''
mdt.batch_fit(
    '/home/robbert/phd-data/rheinland/',
    model_names,
    batch_profile=RheinLandBatchProfile(resolutions_to_use=['data_ms20']))

mdt.batch_fit('/home/robbert/phd-data/hcp_mgh/',
              model_names,
              batch_profile='HCP_MGH')


def func(subject_info):
    subject_id = subject_info.subject_id

    wm_mask = generate_simple_wm_mask(os.path.join(
        subject_info.data_folder[:-1] + '_output', subject_id, 'Tensor',
        'Tensor.FA.nii.gz'),
                                      subject_info.get_input_data().mask,
                                      threshold=0.3,