当前位置: 首页>>代码示例>>Python>>正文


Python layout.BIDSLayout方法代码示例

本文整理汇总了Python中bids.layout.BIDSLayout方法的典型用法代码示例。如果您正苦于以下问题:Python layout.BIDSLayout方法的具体用法?Python layout.BIDSLayout怎么用?Python layout.BIDSLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bids.layout的用法示例。


在下文中一共展示了layout.BIDSLayout方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def init(cls):
        """Create a new BIDS Layout accessible with :attr:`~execution.layout`."""
        if cls._layout is None:
            import re
            from bids.layout import BIDSLayout

            work_dir = cls.work_dir / "bids.db"
            work_dir.mkdir(exist_ok=True, parents=True)
            cls._layout = BIDSLayout(
                str(cls.bids_dir),
                validate=False,
                # database_path=str(work_dir),
                ignore=(
                    "code",
                    "stimuli",
                    "sourcedata",
                    "models",
                    "derivatives",
                    re.compile(r"^\."),
                ),
            )
        cls.layout = cls._layout


# These variables are not necessary anymore 
开发者ID:poldracklab,项目名称:mriqc,代码行数:27,代码来源:config.py

示例2: write_full_report

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def write_full_report(report_dict, run_context, deriv_dir):
    fl_layout = BIDSLayout(
        deriv_dir, config=['bids', 'derivatives', 'fitlins'])

    env = jinja2.Environment(
        loader=jinja2.FileSystemLoader(
            searchpath=pkgr.resource_filename('fitlins', '/')))

    tpl = env.get_template('data/full_report.tpl')

    model = snake_to_camel(report_dict['model']['name'])
    target_file = op.join(
        deriv_dir, fl_layout.build_path(
            {'model': model}, PATH_PATTERNS, validate=False))
    html = tpl.render(deroot({**report_dict, **run_context}, op.dirname(target_file)))
    Path(target_file).write_text(html) 
开发者ID:poldracklab,项目名称:fitlins,代码行数:18,代码来源:reports.py

示例3: __get_bids_layout

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def __get_bids_layout(self):
        '''run the BIDS validator and produce the bids_layout'''
        run("bids-validator {}".format(self.bids_dir),  dryrun = DRYRUN)
        try:
            layout = BIDSLayout(self.bids_dir, exclude=['derivatives'])
        except:
            logger.critical('Could not parse <bids_dir> {}'.format(self.bids_dir))
            sys.exit(1)
        return layout 
开发者ID:edickie,项目名称:ciftify,代码行数:11,代码来源:fmriprep_ciftify.py

示例4: __get_from_bids_layout

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def __get_from_bids_layout(self, user_arg, entity):
        '''for a given BIDSLayout entity, check the layout against the user arguments'''
        all_ids = self.bids_layout.get(return_type = "id", target = entity)
        if user_arg:
            ids_to_analyze = user_arg.split(",")
            for label in ids_to_analyze:
                if label not in all_ids:
                    logger.critical("{} {} not in bids_dir".format(entity, label))
                    sys.exit(1)
        # for all subjects
        else:
            ids_to_analyze = all_ids
        return ids_to_analyze 
开发者ID:edickie,项目名称:ciftify,代码行数:15,代码来源:fmriprep_ciftify.py

示例5: get_derivatives_layout

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def get_derivatives_layout(derivs_dir):
    '''run pybids and produce the derivs_layout'''
    try:
        derivs_layout = BIDSLayout(derivs_dir,
             validate = False, config = ['bids', 'derivatives'])
    except:
        logger.warning('Could not parse BIDS derivatives from {}'.format(derivs_dir))
    return derivs_layout 
开发者ID:edickie,项目名称:ciftify,代码行数:10,代码来源:fmriprep_ciftify.py

示例6: testlayout

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def testlayout():
    data_dir = join(get_test_data_path(), 'synthetic')
    return BIDSLayout(data_dir) 
开发者ID:bids-standard,项目名称:pybids,代码行数:5,代码来源:test_parsing.py

示例7: model

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def model():
    layout_path = join(get_test_data_path(), 'ds005')
    layout = BIDSLayout(layout_path)

    models = auto_model(layout, scan_length=480, one_vs_rest=True)

    return models[0] 
开发者ID:bids-standard,项目名称:pybids,代码行数:9,代码来源:test_automodel.py

示例8: test_auto_model_analysis

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def test_auto_model_analysis(model):

    layout_path = join(get_test_data_path(), 'ds005')
    layout = BIDSLayout(layout_path)

    # Test to make sure an analaysis can be setup from the generated model
    analysis = Analysis(layout, model)
    analysis.setup(scan_length=480)

    assert model['Name'] == 'ds005_mixedgamblestask'

    # run level
    block = model['Steps'][0]
    assert block['Name'] == 'Run'
    assert block['Level'] == 'Run'
    assert block['Transformations'][0]['Name'] == 'Factor'
    assert block['Contrasts'][0]['Name'] == 'run_parametric gain'
    assert block['Contrasts'][0]['Weights'] == [1]
    assert block['Contrasts'][0]['Type'] == 't'

    # subject level
    block = model['Steps'][1]
    assert block['Name'] == 'Subject'
    assert block['Level'] == 'Subject'
    assert block['Model']['X'][0] == 'run_parametric gain'
    assert block['Contrasts'][0]['Name'] == 'subject_run_parametric gain'
    assert block['Contrasts'][0]['Type'] == 'FEMA'

    # dataset level
    block = model['Steps'][2]
    assert block['Name'] == 'Dataset'
    assert block['Level'] == 'Dataset'
    assert block['Model']['X'][0] == 'subject_run_parametric gain'
    assert block['Contrasts'][0]['Name'] == 'dataset_subject_run_parametric gain'
    assert block['Contrasts'][0]['Type'] == 't' 
开发者ID:bids-standard,项目名称:pybids,代码行数:37,代码来源:test_automodel.py

示例9: collection

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def collection():
    if 'ds005' not in cached_collections:
        layout_path = join(get_test_data_path(), 'ds005')
        layout = BIDSLayout(layout_path)
        cached_collections['ds005'] = layout.get_collections(
            'run',
            types=['events'],
            scan_length=SCAN_LENGTH,
            merge=True,
            sampling_rate=10,
            subject=SUBJECTS
        )
    # Always return a clone!
    return cached_collections['ds005'].clone() 
开发者ID:bids-standard,项目名称:pybids,代码行数:16,代码来源:test_transformations.py

示例10: __init__

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def __init__(self, layout, model):

        if not isinstance(layout, BIDSLayout):
            layout = BIDSLayout(layout)
        self.layout = layout

        self._load_model(model) 
开发者ID:bids-standard,项目名称:pybids,代码行数:9,代码来源:analysis.py

示例11: init_layout

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def init_layout(self):
        self.layout = BIDSLayout(self.root, config="figures", validate=False) 
开发者ID:nipreps,项目名称:niworkflows,代码行数:4,代码来源:core.py

示例12: test_generated_reportlets

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def test_generated_reportlets(bids_sessions, ordering):
    # make independent report
    out_dir = tempfile.mkdtemp()
    report = Report(
        Path(out_dir),
        "fakeuuid",
        reportlets_dir=Path(bids_sessions),
        subject_id="01",
        packagename="fmriprep",
    )
    config = Path(pkgrf("niworkflows", "reports/default.yml"))
    settings = load(config.read_text())
    # change settings to only include some missing ordering
    settings["sections"][3]["ordering"] = ordering
    report.index(settings["sections"])
    # expected number of reportlets
    expected_reportlets_num = len(report.layout.get(extension="svg"))
    # bids_session uses these entities
    needed_entities = ["session", "task", "ceagent", "run"]
    # the last section is the most recently run
    reportlets_num = len(report.sections[-1].reportlets)
    # get the number of figures in the output directory
    out_layout = BIDSLayout(out_dir, config="figures", validate=False)
    out_figs = len(out_layout.get())
    # if ordering does not contain all the relevent entities
    # then there should be fewer reportlets than expected
    if all(ent in ordering for ent in needed_entities):
        assert reportlets_num == expected_reportlets_num == out_figs
    else:
        assert reportlets_num < expected_reportlets_num == out_figs 
开发者ID:nipreps,项目名称:niworkflows,代码行数:32,代码来源:test_core.py

示例13: _process_orderings

# 需要导入模块: from bids import layout [as 别名]
# 或者: from bids.layout import BIDSLayout [as 别名]
def _process_orderings(orderings, layout):
        """
        Generate relevant combinations of orderings with observed values.

        Arguments
        ---------
        orderings : :obj:`list` of :obj:`list` of :obj:`str`
            Sections prescribing an ordering to select across sessions, acquisitions, runs, etc.
        layout : :obj:`bids.layout.BIDSLayout`
            The BIDS layout

        Returns
        -------
        entities: :obj:`list` of :obj:`str`
            The relevant orderings that had unique values
        value_combos: :obj:`list` of :obj:`tuple`
            Unique value combinations for the entities

        """
        # get a set of all unique entity combinations
        all_value_combos = {
            tuple(bids_file.get_entities().get(k, None) for k in orderings)
            for bids_file in layout.get()
        }
        # remove the all None member if it exists
        none_member = tuple([None for k in orderings])
        if none_member in all_value_combos:
            all_value_combos.remove(tuple([None for k in orderings]))
        # see what values exist for each entity
        unique_values = [
            {value[idx] for value in all_value_combos} for idx in range(len(orderings))
        ]
        # if all values are None for an entity, we do not want to keep that entity
        keep_idx = [
            False if (len(val_set) == 1 and None in val_set) or not val_set else True
            for val_set in unique_values
        ]
        # the "kept" entities
        entities = list(compress(orderings, keep_idx))
        # the "kept" value combinations
        value_combos = [
            tuple(compress(value_combo, keep_idx)) for value_combo in all_value_combos
        ]
        # sort the value combinations alphabetically from the first entity to the last entity
        value_combos.sort(
            key=lambda entry: tuple(
                str(value) if value is not None else "0" for value in entry
            )
        )

        return entities, value_combos 
开发者ID:nipreps,项目名称:niworkflows,代码行数:53,代码来源:core.py


注:本文中的bids.layout.BIDSLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。