DrSAR / SARlabpy

git clone git@pfeifer.phas.ubc.ca:SARlabpy (do not push to github, please)
http://code.SARlab.ca
Other
1 stars 0 forks source link

added needed functionality to masterlists by hack... #349

Open firasm opened 8 years ago

firasm commented 8 years ago

Since we have been doing a lot of phantom experiments recently, the need has arisen for a way to get all scan labels from a particular study. We chose to keep the "patient" the same to keep all the phantom experiments together, and that makes sense.

screen shot 2015-07-27 at 8 58 18 pm

I added this functionality by way of a function: sarpy.helpers.getLabelsByStudy()

def getLabelsByStudy(masterlist_name, studyAbbr = 'wL1'):

    experimentList = sarpy.Experiment.from_masterlist('cest_FM.config')

    newExpList = defaultdict(list)

    for k,v in experimentList.labels.iteritems():

        studyInK = False

        for scan in v:

            if studyAbbr in scan:

                newExpList[k].append(scan)

    return dict(newExpList)

this yields a nicely formatted dictionary:

sarpy.helpers.getLabelsByStudy('cest_FM.config','wL1')

{'cert1': ['cest_FM.wL1/23'],
 'cert2': ['cest_FM.wL1/24'],
 'epi_1sh': ['cest_FM.wL1/16'],
 'epi_2sh': ['cest_FM.wL1/17'],
 'full_1sh_cw': ['cest_FM.wL1/25'],
 'full_1sh_pulsed': ['cest_FM.wL1/19'],
 'full_2sh_cw': ['cest_FM.wL1/27'],
 'full_2sh_pulsed': ['cest_FM.wL1/26'],
 'repeat_1sh_6': ['cest_FM.wL1/10'],
 'repeat_1sh_66': ['cest_FM.wL1/8'],
 'repeat_1sh_66_wait': ['cest_FM.wL1/9'],
 'repeat_1sh_6_wait': ['cest_FM.wL1/11'],
 'repeat_1sh_epi': ['cest_FM.wL1/16'],
 'repeat_2sh_6': ['cest_FM.wL1/14'],
 'repeat_2sh_66': ['cest_FM.wL1/12'],
 'repeat_2sh_66_wait': ['cest_FM.wL1/13'],
 'repeat_2sh_6_wait': ['cest_FM.wL1/15'],
 'repeat_2sh_epi': ['cest_FM.wL1/17']}

Not sure if this is too specialized a case to include in the general functionality of masterlists - this will serve my purpose, even if there are no changes made.