def getSesh(subjVal, eTypeVal): seshList = hf.sessionPerDRG(subjVal, eTypeVal) seshDrop = [] for iDRG in sorted(seshList.keys()): for iSesh in sorted(seshList[iDRG]): seshDrop.append({ 'label': 'session %d (%s)' % (iSesh, iDRG), 'value': iSesh }) return seshDrop
subjectList = hf.getSubjects(eType) allDRG = hf.allDRG meanAmpDict = dict.fromkeys(subjectList) for subject in subjectList: meanAmpDict[subject] = {} for DRG in allDRG: meanAmpDict[subject][DRG] = {} for cuff in allCuffs: meanAmpDict[subject][DRG][cuff] = [] for subject in subjectList: seshDict = {} # returns all sessions per DRG per subject res2 = hf.sessionPerDRG( subject) # add arguemnt for penetrating vs epineural res3 = hf.sessionPerElectrodeType(subject) # iterate over each DRG for iDRG in res2['result']: if iDRG['DRG'] in allDRG: allEtypeSesh = res3[eType] targetSesh = sorted( [value for value in allEtypeSesh if value in iDRG['session']]) # iterate over each session for sesh in targetSesh: threshDict = hf.thresholdPerCuff(subject, sesh, allCuffs, False) allActiveChans = sorted(threshDict.keys()) numActiveChans = len(allActiveChans)
normFactor = [] subjectRow = 0 # fig_numCh = tools.make_subplots(rows=len(subjectList), cols=len(allDRG), subplot_titles=allDRG*len(allDRG)) # fig_meanA = tools.make_subplots(rows=len(subjectList), cols=len(allDRG), subplot_titles=allDRG*len(allDRG)) # fig_numChan = tools.make_subplots(rows=1, cols=len(allDRG), subplot_titles=allDRG) fig_meanAmp = tools.make_subplots(rows=len(allDRG), cols=1, subplot_titles=allDRG) # for subject in subjectList: for iDRG in allDRG: for subject in subjectList: subjectRow = subjectList.index(subject) + 1 # returns all sessions per iDRG per subject res2 = hf.sessionPerDRG(subject, eType) # iterate over each iDRG # for iDRG in res2.keys(): subjectNumChanDict = dict.fromkeys(targetNerveLabels, 0) subjectMeanAmpDict = {k: [] for k in targetNerveLabels} subjectCol = allDRG.index(iDRG) + 1 if iDRG in res2.keys(): targetSesh = res2[iDRG] #sorted([value for value in allEtypeSesh if value in res2[iDRG]]) for sesh in targetSesh: threshDict = hf.thresholdPerCuff(subject, sesh, ignoreCuffs, collapseCuffs,stimUnits=stimunit) allActiveChans = sorted(threshDict.keys())
colorList = hf.colorOrder subjectList = hf.getSubjects(eType) targetNerveLabels = hf.allCuffs_mdf.keys() coactivationDF = pd.DataFrame(0, columns=targetNerveLabels, index=targetNerveLabels) coactivationDict_perDRG = {} for iDRG in hf.allDRG: coactivationDF_perDRG = pd.DataFrame(0, columns=targetNerveLabels, index=targetNerveLabels) for subject in subjectList: seshPerDRG = hf.sessionPerDRG( subject, eType) # add argument for penetrating vs epineural if iDRG in seshPerDRG.keys(): # iterate over each session for iSesh in seshPerDRG[iDRG]: threshDict = hf.thresholdPerCuff(subject, iSesh, ignoreCuffs, collapseCuffs) threshChans = sorted(threshDict.keys()) discardChans = hf.getSingleAmplitudeChannels(subject, iSesh) allStimChans = [ chans for chans in threshChans if chans not in discardChans ] binaryRes = hf.convertCurrentToCharge( hf.binarySearchResolutionbySession[subject][iSesh], subject, iSesh)
from helperFcns import plt sns.set(style="white", color_codes=True) from itertools import chain import scipy eType = 'penetrating' stimUnits = 'charge' # f, violinAx = plt.subplots(1, 2, figsize=(14, 5)) cvList = [] i = 0 for eType in ['penetrating', 'epineural']: subjectList = hf.getSubjects(eType) for nerve in ['Femoral', 'Sciatic']: for iSub in subjectList: seshPerDRG = hf.sessionPerDRG(iSub, eType) allSessions = sum(seshPerDRG.values(), []) for iSesh in allSessions: res = hf.db.command({ 'aggregate': hf.collection, 'pipeline': [{ '$match': { "mdf_metadata.subject": iSub, "mdf_metadata.session": iSesh, "mdf_metadata.location": nerve, "mdf_def.mdf_type": 'CV', "mdf_metadata.is_sig_manual": { "$in": [1, None] },