Beispiel #1
0
 def test_pipeline_3(self):
     pipeline = load_pipeline_from_json(
         get_pipeline_path('pipeline-24HMP_aCompCor_SpikeReg'))
     summary = get_pipeline_summary(pipeline)
     for confound in summary:
         if confound['Confound'] == 'WM':
             self.assertEqual(confound['Raw'], NO)
             self.assertEqual(confound["Temp. deriv."], NO)
             self.assertEqual(confound["Quadr. terms"], NO)
         elif confound['Confound'] == 'CSF':
             self.assertEqual(confound['Raw'], NO)
             self.assertEqual(confound["Temp. deriv."], NO)
             self.assertEqual(confound["Quadr. terms"], NO)
         elif confound['Confound'] == 'GS':
             self.assertEqual(confound['Raw'], NO)
             self.assertEqual(confound["Temp. deriv."], NO)
             self.assertEqual(confound["Quadr. terms"], NO)
         elif confound['Confound'] == 'aCompCor':
             self.assertEqual(confound['Raw'], YES)
             self.assertEqual(confound["Temp. deriv."], NA)
             self.assertEqual(confound["Quadr. terms"], NA)
         elif confound['Confound'] == 'ICA-AROMA':
             self.assertEqual(confound['Raw'], NO)
             self.assertEqual(confound["Temp. deriv."], NA)
             self.assertEqual(confound["Quadr. terms"], NA)
         elif confound['Confound'] == 'Spikes':
             self.assertEqual(confound['Raw'], YES)
             self.assertEqual(confound["Temp. deriv."], NA)
             self.assertEqual(confound["Quadr. terms"], NA)
         else:
             raise ValueError(f'Unknown confound {confound}')
Beispiel #2
0
def parse_pipelines(pipelines_args: str or set = "all") -> set:
    """
    Parses all possible pipeline options:
    :param pipelines_args: set or str, only valid string argument is 'all'.
    If argument is set it can containing both names of pipelines from
    fmridenoise.pipelines directory or path(s) to valid json file(s)
    containing of valid pipeline description.
    :return: set of valid pipelines paths.
    """
    if type(pipelines_args) is str:
        if pipelines_args != "all":
            raise ValueError("Only valid string argument is 'all'")
        else:
            return get_pipelines_paths()
    known_pipelines = get_pipelines_names()
    pipelines_args = set(pipelines_args)
    if pipelines_args <= known_pipelines:
        return get_pipelines_paths(pipelines_args)
    ret = set()
    for p in pipelines_args:
        if p in known_pipelines:
            ret.add(get_pipeline_path(p))
        elif p not in known_pipelines and is_valid(
                ut.load_pipeline_from_json(p)):
            ret.add(p)
        else:
            raise ValueError(f"File: '{p} is not a valid pipeline")
    return ret
Beispiel #3
0
 def _run_interface(self, runtime):
     js = load_pipeline_from_json(self.inputs.pipeline_path)
     if not is_valid(js):
         raise ValueError("""
         Json file {} is not a valid pipeline, 
         check schema at fmridenoise.utils.json_validator.py
         """.format(os.path.basename(self.inputs.pipeline_path)))
     self._results['pipeline'] = js
     return runtime
Beispiel #4
0
    data_dict = create_pipelines_data_dict(data_path, pipelines_list)
    data_dict['group'] = {}
    data_dict['group']['img'] = {
        'Edges_Density': 'pipelines_edges_density.svg',
        'Edges_Density_No_High_Motion':
        'pipelines_edges_density_no_high_motion.svg',
        'Pipelines_Distance_Dependency': 'pipelines_distance_dependence.svg',
        'Pipelines_FC_FC_Pearson': 'pipelines_fc_fd_pearson.svg',
        'Motion_Out':
        basename(glob.glob(join(data_path, 'motion_criterion*'))[0]),
        'Tdof_Loss': 'pipelines_tdof_loss.svg'
    }
    html = tpl.render(data_dict,
                      excluded_subjects=excluded_subjects,
                      css=css,
                      script=script)
    with open(join(data_path, 'report.html'), 'w') as report_file:
        report_file.write(html)


if __name__ == '__main__':
    from fmridenoise.utils.utils import load_pipeline_from_json
    from fmridenoise.pipelines import get_pipeline_path, get_pipelines_paths
    path = '/home/siegfriedwagner/Music/fmridenoise_output_neuroinformatics'
    # pipelines_list = [load_pipeline_from_json(get_pipeline_path('pipeline-Null')),
    #                   load_pipeline_from_json(get_pipeline_path('pipeline-24HMP_8Phys_SpikeReg'))]
    pipelines_list = [
        load_pipeline_from_json(pipeline_path)
        for pipeline_path in get_pipelines_paths()
    ]
    create_report(path, pipelines_list, ['sub-46'])