Skip to content
Snippets Groups Projects
Commit 2538b45e authored by Paul McCarthy's avatar Paul McCarthy
Browse files

FEAT things do not crash if the feat directory has no stats.

parent 776485b6
No related branches found
No related tags found
No related merge requests found
......@@ -72,8 +72,13 @@ class FEATImage(fslimage.Image):
featDir = op.dirname(path)
settings = featresults.loadSettings( featDir)
design = featresults.loadDesign( featDir)
names, cons = featresults.loadContrasts(featDir)
if featresults.hasStats(featDir):
design = featresults.loadDesign( featDir)
names, cons = featresults.loadContrasts(featDir)
else:
design = np.zeros((0, 0))
names, cons = [], []
fslimage.Image.__init__(self, path, **kwargs)
......@@ -113,6 +118,13 @@ class FEATImage(fslimage.Image):
is not part of another analysis.
"""
return featresults.getTopLevelAnalysisDir(self.__featDir)
def hasStats(self):
"""Returns ``True`` if the analysis for this ``FEATImage`` contains
a statistical analysis.
"""
return self.__design.size > 0
def getDesign(self):
......
......@@ -15,6 +15,7 @@ following functions are provided:
isFEATImage
isFEATDir
hasStats
hasMelodicDir
getAnalysisDir
getTopLevelAnalysisDir
......@@ -97,6 +98,17 @@ def isFEATDir(path):
return True
def hasStats(featdir):
"""Returns ``True`` if it looks like statistics have been calculated
for the given FEAT analysis, ``False`` otherwise.
"""
statdir = op.join(featdir, 'stats')
statfiles = glob.glob(op.join(statdir, '*'))
return op.exists(statdir) and len(statfiles) > 0
def hasMelodicDir(featdir):
"""Returns ``True`` if the data for the given FEAT directory has had
MELODIC run on it, ``False`` otherwise.
......
......@@ -116,8 +116,9 @@ class TimeSeriesControlPanel(plotcontrolpanel.PlotControlPanel):
overlay = ts.overlay
widgets = self.getWidgetList()
if not (isinstance(overlay, fslfeatimage.FEATImage) and
isinstance(ts, timeseries.FEATTimeSeries)):
if not (isinstance(overlay, fslfeatimage.FEATImage) and
isinstance(ts, timeseries.FEATTimeSeries) and
overlay.hasStats()):
return
full = props.makeWidget( widgets, ts, 'plotFullModelFit')
......
......@@ -274,6 +274,9 @@ class FEATTimeSeries(VoxelTimeSeries):
self.__evTs = [None] * numEVs
self.__peTs = [None] * numEVs
self.__copeTs = [None] * numCOPEs
if not self.overlay.hasStats():
self.plotFullModelFit = False
self.addListener('plotFullModelFit',
self.name,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment