neuroscout/populate/convert.py
def save_stim_filename(stimulus):
    """ Given a pliers stimulus object, create a hash, filename, and save.
        If type if TextStim or ComplexTextStim, return content rather than path
    """
    if isinstance(stimulus, TextStim):
        stimulus = ComplexTextStim(text=stimulus.data, onset=stimulus.onset,
                                   duration=stimulus.duration)

    stim_hash = hash_stim(stimulus)

    if isinstance(stimulus, ComplexTextStim):
        return stim_hash, None, stimulus.data, stimulus.name
    else:
        basepath = Path(current_app.config['STIMULUS_DIR']).absolute()

        stim_types = {ImageStim: '.png',
                      VideoFrameStim: '.png',
                      VideoStim: '.mkv',
                      AudioStim: '.wav'}

        ext = [e for c, e in stim_types.items() if isinstance(stimulus, c)][0]
        path = (basepath / stim_hash).with_suffix(ext)

        path.parents[0].mkdir(exist_ok=True)
        stimulus.save(path.as_posix())

        return stim_hash, path, None, None
 Given a pliers stimulus object, create a hash, filename, and save.
        If type if TextStim or ComplexTextStim, return content rather than path
    
Given a pliers stimulus object, create a hash, filename, and save.
If type if TextStim or ComplexTextStim, return content rather than path
Given a pliers stimulus object create a hash filename and save . If type if TextStim or ComplexTextStim return content rather than path
def save_stim_filename(stimulus):
    if isinstance(stimulus, TextStim):
        stimulus = ComplexTextStim(text=stimulus.data, onset=stimulus.onset,
                                   duration=stimulus.duration)
    stim_hash = hash_stim(stimulus)
    if isinstance(stimulus, ComplexTextStim):
        return stim_hash, None, stimulus.data, stimulus.name
    else:
        basepath = Path(current_app.config['STIMULUS_DIR']).absolute()
        stim_types = {ImageStim: '.png',
                      VideoFrameStim: '.png',
                      VideoStim: '.mkv',
                      AudioStim: '.wav'}
        ext = [e for c, e in stim_types.items() if isinstance(stimulus, c)][0]
        path = (basepath / stim_hash).with_suffix(ext)
        path.parents[0].mkdir(exist_ok=True)
        stimulus.save(path.as_posix())
        return stim_hash, path, None, None
def save_stim_filename ( stimulus ) : if isinstance ( stimulus , TextStim ) : stimulus = ComplexTextStim ( text = stimulus . data , onset = stimulus . onset , duration = stimulus . duration ) stim_hash = hash_stim ( stimulus ) if isinstance ( stimulus , ComplexTextStim ) : return stim_hash , None , stimulus . data , stimulus . name else : basepath = Path ( current_app . config [ 'STIMULUS_DIR' ] ) . absolute ( ) stim_types = { ImageStim : '.png' , VideoFrameStim : '.png' , VideoStim : '.mkv' , AudioStim : '.wav' } ext = [ e for c , e in stim_types . items ( ) if isinstance ( stimulus , c ) ] [ 0 ] path = ( basepath / stim_hash ) . with_suffix ( ext ) path . parents [ 0 ] . mkdir ( exist_ok = True ) stimulus . save ( path . as_posix ( ) ) return stim_hash , path , None , None
Given a pliers stimulus object, create a hash, filename, and save.
Given a pliers stimulus object create a hash filename and save .
""" Given a pliers stimulus object, create a hash, filename, and save.
        If type if TextStim or ComplexTextStim, return content rather than path
    """
stimulus