neuroscout/tasks/utils/build.py
def build_analysis(analysis, predictor_events, bids_dir,
                   run_ids=None, build=True):
    """ Write out and build analysis object """

    if predictor_events == []:
        raise Exception("Error: Predictor events are null")

    tmp_dir = Path(mkdtemp())

    # Get durations and set of entities across analysis runs
    if run_ids is None:
        run_entities = [(run['duration'], _get_entities(run)) for run in analysis['runs']]
    else:
        run_entities = []
        for rid in run_ids:
            for run in analysis['runs']:
                if rid == run['id']:
                    run_entities.append((run['duration'], _get_entities(run)))
                    break

    # Write out all events
    paths = writeout_events(
        analysis, predictor_events, tmp_dir, run_ids)

    if build is False:
        bids_analysis = None
    else:
        bids_layout = _load_cached_layout(
            bids_dir, analysis['dataset_id'])
        bids_layout.add_derivatives(str(tmp_dir))

        bids_analysis = BIDSAnalysis(
            bids_layout, deepcopy(analysis.get('model')))

        for dur, ents in run_entities:
            bids_analysis.setup(**ents, scan_length=dur)

    return tmp_dir, paths, bids_analysis
 Write out and build analysis object 
Write out and build analysis object
Write out and build analysis object
def build_analysis(analysis, predictor_events, bids_dir,
                   run_ids=None, build=True):
    if predictor_events == []:
        raise Exception("Error: Predictor events are null")
    tmp_dir = Path(mkdtemp())
    if run_ids is None:
        run_entities = [(run['duration'], _get_entities(run)) for run in analysis['runs']]
    else:
        run_entities = []
        for rid in run_ids:
            for run in analysis['runs']:
                if rid == run['id']:
                    run_entities.append((run['duration'], _get_entities(run)))
                    break
    paths = writeout_events(
        analysis, predictor_events, tmp_dir, run_ids)
    if build is False:
        bids_analysis = None
    else:
        bids_layout = _load_cached_layout(
            bids_dir, analysis['dataset_id'])
        bids_layout.add_derivatives(str(tmp_dir))
        bids_analysis = BIDSAnalysis(
            bids_layout, deepcopy(analysis.get('model')))
        for dur, ents in run_entities:
            bids_analysis.setup(**ents, scan_length=dur)
    return tmp_dir, paths, bids_analysis
def build_analysis ( analysis , predictor_events , bids_dir , run_ids = None , build = True ) : if predictor_events == [ ] : raise Exception ( "Error: Predictor events are null" ) tmp_dir = Path ( mkdtemp ( ) ) if run_ids is None : run_entities = [ ( run [ 'duration' ] , _get_entities ( run ) ) for run in analysis [ 'runs' ] ] else : run_entities = [ ] for rid in run_ids : for run in analysis [ 'runs' ] : if rid == run [ 'id' ] : run_entities . append ( ( run [ 'duration' ] , _get_entities ( run ) ) ) break paths = writeout_events ( analysis , predictor_events , tmp_dir , run_ids ) if build is False : bids_analysis = None else : bids_layout = _load_cached_layout ( bids_dir , analysis [ 'dataset_id' ] ) bids_layout . add_derivatives ( str ( tmp_dir ) ) bids_analysis = BIDSAnalysis ( bids_layout , deepcopy ( analysis . get ( 'model' ) ) ) for dur , ents in run_entities : bids_analysis . setup ( ** ents , scan_length = dur ) return tmp_dir , paths , bids_analysis
Write out and build analysis object
Write out and build analysis object
""" Write out and build analysis object """ # Get durations and set of entities across analysis runs # Write out all events
analysis
predictor_events
bids_dir
run_ids
build