def temporalPlot(figAxis, trial, pointLabel, axis, pointLabelSuffix=None, color=None, title=None, xlabel=None, ylabel=None, ylim=None, legendLabel=None, customLimits=None): ''' **Description :** plot descriptive statistical (average and sd corridor) gait traces from a pyCGM2.Processing.analysis.Analysis instance :Parameters: - `figAxis` (matplotlib::Axis ) - `trial` (ma.Trial) - a Structure item of an Analysis instance built from AnalysisFilter :Return: - matplotlib figure **Usage** .. code:: python ''' pointLabel = pointLabel + "_" + pointLabelSuffix if pointLabelSuffix is not None else pointLabel flag = trialTools.isTimeSequenceExist(trial, pointLabel) if flag: timeseq = trial.findChild(ma.T_TimeSequence, pointLabel) lines = figAxis.plot(timeseq.data()[:, axis], '-', color=color) if legendLabel is not None and flag: lines[0].set_label(legendLabel) if title is not None: figAxis.set_title(title, size=8) figAxis.tick_params(axis='x', which='major', labelsize=6) figAxis.tick_params(axis='y', which='major', labelsize=6) if xlabel is not None: figAxis.set_xlabel(xlabel, size=8) if ylabel is not None: figAxis.set_ylabel(ylabel, size=8) if ylim is not None: figAxis.set_ylim(ylim) if flag: for ev in trial.findChildren(ma.T_Event): colorContext = plotUtils.colorContext(ev.context()) if ev.name() == "Foot Strike": figAxis.axvline(x=(ev.time() - timeseq.startTime()) * timeseq.sampleRate(), color=colorContext, linestyle="-") elif ev.name() == "Foot Off": figAxis.axvline(x=(ev.time() - timeseq.startTime()) * timeseq.sampleRate(), color=colorContext, linestyle="--")
def __setData(self): #suffixPlus = "_" + self.m_pointLabelSuffix if self.m_pointLabelSuffix!="" else "" for i in range(0, len(self.emgs)): label = self.emgs[i]["Label"]+"_Rectify" if self.rectify else self.emgs[i]["Label"]+"_HPF" context = self.emgs[i]["Context"] colorContext = plotUtils.colorContext(context) normalActivationLabel = self.m_normalActivEmgs[i] plot.temporalPlot(self.fig.axes[i],self.m_trial, label,0, color=colorContext) plot.addTemporalNormalActivationLayer(self.fig.axes[i],self.m_trial,self.m_normalActivEmgs[i],context)
def __setData(self): #suffixPlus = "_" + self.m_pointLabelSuffix if self.m_pointLabelSuffix!="" else "" for i in range(0, len(self.emgs)): label = self.emgs[i]["Label"]+"_Rectify_Env" if not self.m_normalizedEmgFlag else self.emgs[i]["Label"]+"_Rectify_Env_Norm" context = self.emgs[i]["Context"] colorContext = plotUtils.colorContext(context) self.m_concretePlotFunction(self.fig.axes[i],self.m_analysis.emgStats, label,context,0,color=colorContext) footOff = self.m_analysis.emgStats.pst['stancePhase', context]["mean"] plot.addNormalActivationLayer(self.fig.axes[i],self.m_normalActivEmgs[i], footOff)
def temporalPlot(figAxis, acq, pointLabel, axis, pointLabelSuffix=None, color=None, title=None, xlabel=None, ylabel=None, ylim=None, legendLabel=None, customLimits=None): ''' **Description :** plot descriptive statistical (average and sd corridor) gait traces from a pyCGM2.Processing.analysis.Analysis instance :Parameters: - `figAxis` (matplotlib::Axis ) - `acq` (ma.Trial) - a Structure item of an Analysis instance built from AnalysisFilter :Return: - matplotlib figure **Usage** .. code:: python ''' pointLabel = pointLabel + "_" + pointLabelSuffix if pointLabelSuffix is not None else pointLabel flag = btkTools.isPointExist(acq, pointLabel) if flag: point = acq.GetPoint(pointLabel) lines = figAxis.plot(point.GetValues()[:, axis], '-', color=color) appf = 1 else: flag = btkTools.isAnalogExist(acq, pointLabel) if flag: analog = acq.GetAnalog(pointLabel) lines = figAxis.plot(analog.GetValues()[:, axis], '-', color=color) appf = acq.GetNumberAnalogSamplePerFrame() if legendLabel is not None and flag: lines[0].set_label(legendLabel) if title is not None: figAxis.set_title(title, size=8) figAxis.tick_params(axis='x', which='major', labelsize=6) figAxis.tick_params(axis='y', which='major', labelsize=6) if xlabel is not None: figAxis.set_xlabel(xlabel, size=8) if ylabel is not None: figAxis.set_ylabel(ylabel, size=8) if ylim is not None: figAxis.set_ylim(ylim) if flag: for ev in btk.Iterate(acq.GetEvents()): colorContext = plotUtils.colorContext(ev.GetContext()) if ev.GetLabel() == "Foot Strike": figAxis.axvline(x=(ev.GetFrame() - acq.GetFirstFrame()) * appf, color=colorContext, linestyle="-") if ev.GetLabel() == "Foot Off": figAxis.axvline(x=(ev.GetFrame() - acq.GetFirstFrame()) * appf, color=colorContext, linestyle="--")