neuroscout/populate/extract.py
def _load_complex_text_stim_models(dataset_name, task_name=None):
    """ Reconstruct ComplexTextStim object of complete run transcript
    for each run in a task """
    stim_models = Stimulus.query.filter_by(
        active=True, mimetype='text/csv').join(
            RunStimulus).join(Run).join(Task)
        
    if task_name is not None:
        stim_models = stim_models.filter_by(name=task_name)
        
    stim_models = stim_models.join(Dataset).filter_by(name=dataset_name)

    stims = []
    print("Loading stim models...")
    for stim_model in tqdm(stim_models):
        # Reconstruct complete ComplexTextStim
        rs_transcript = stim_model.run_stimuli.first()
        run_words = Stimulus.query.filter_by(
            mimetype='text/plain').join(RunStimulus).filter_by(
                run_id=rs_transcript.run_id)

        word_stims = []
        for w in run_words:
            for w_rs in w.run_stimuli.filter_by(run_id=rs_transcript.run_id):
                word_stims.append(
                    TextStim(
                        text=w.content, onset=w_rs.onset-rs_transcript.onset,
                        duration=w_rs.duration)
                    )
        word_stims = sorted(word_stims, key=lambda x: x.onset)
        stims.append((stim_model, ComplexTextStim(elements=word_stims)))

    return stims
 Reconstruct ComplexTextStim object of complete run transcript
    for each run in a task 
Reconstruct ComplexTextStim object of complete run transcript
for each run in a task
Reconstruct ComplexTextStim object of complete run transcript for each run in a task
def _load_complex_text_stim_models(dataset_name, task_name=None):
    stim_models = Stimulus.query.filter_by(
        active=True, mimetype='text/csv').join(
            RunStimulus).join(Run).join(Task)
    if task_name is not None:
        stim_models = stim_models.filter_by(name=task_name)
    stim_models = stim_models.join(Dataset).filter_by(name=dataset_name)
    stims = []
    print("Loading stim models...")
    for stim_model in tqdm(stim_models):
        rs_transcript = stim_model.run_stimuli.first()
        run_words = Stimulus.query.filter_by(
            mimetype='text/plain').join(RunStimulus).filter_by(
                run_id=rs_transcript.run_id)
        word_stims = []
        for w in run_words:
            for w_rs in w.run_stimuli.filter_by(run_id=rs_transcript.run_id):
                word_stims.append(
                    TextStim(
                        text=w.content, onset=w_rs.onset-rs_transcript.onset,
                        duration=w_rs.duration)
                    )
        word_stims = sorted(word_stims, key=lambda x: x.onset)
        stims.append((stim_model, ComplexTextStim(elements=word_stims)))
    return stims
def _load_complex_text_stim_models ( dataset_name , task_name = None ) : stim_models = Stimulus . query . filter_by ( active = True , mimetype = 'text/csv' ) . join ( RunStimulus ) . join ( Run ) . join ( Task ) if task_name is not None : stim_models = stim_models . filter_by ( name = task_name ) stim_models = stim_models . join ( Dataset ) . filter_by ( name = dataset_name ) stims = [ ] print ( "Loading stim models..." ) for stim_model in tqdm ( stim_models ) : rs_transcript = stim_model . run_stimuli . first ( ) run_words = Stimulus . query . filter_by ( mimetype = 'text/plain' ) . join ( RunStimulus ) . filter_by ( run_id = rs_transcript . run_id ) word_stims = [ ] for w in run_words : for w_rs in w . run_stimuli . filter_by ( run_id = rs_transcript . run_id ) : word_stims . append ( TextStim ( text = w . content , onset = w_rs . onset - rs_transcript . onset , duration = w_rs . duration ) ) word_stims = sorted ( word_stims , key = lambda x : x . onset ) stims . append ( ( stim_model , ComplexTextStim ( elements = word_stims ) ) ) return stims
Reconstruct ComplexTextStim object of complete run transcript
for each run in a task
Reconstruct ComplexTextStim object of complete run transcript for each run in a task
""" Reconstruct ComplexTextStim object of complete run transcript
    for each run in a task """ # Reconstruct complete ComplexTextStim
dataset_name
task_name