Skip to content
Snippets Groups Projects
Commit 487123d7 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF,BF: FEATImage.getCOPE was loading PE image. Clear refs to images on delete.

parent 94ef1366
No related branches found
No related tags found
No related merge requests found
......@@ -357,6 +357,9 @@ def loadClusterResults(featdir, settings, contrast):
clusterFile = op.join(
featdir, 'cluster_zstat{}_std.txt'.format(contrast + 1))
if not op.exists(clusterFile):
return None
# In higher levle analysis run in some standard
# space, the cluster coordinates are in standard
# space. We transform them to voxel coordinates.
......@@ -365,9 +368,6 @@ def loadClusterResults(featdir, settings, contrast):
getDataFile(featdir),
loadData=False).worldToVoxMat
if not op.exists(clusterFile):
return None
log.debug('Loading cluster results for contrast {} from {}'.format(
contrast, clusterFile))
......
......@@ -95,6 +95,16 @@ class FEATImage(fslimage.Image):
self.name = '{}: {}'.format(self.__analysisName, self.name)
def __del__(self):
"""Clears references to any loaded images."""
self.__design = None
self.__residuals = None
self.__pes = None
self.__copes = None
self.__zstats = None
self.__clustMasks = None
def getFEATDir(self):
"""Returns the FEAT directory this image is contained in."""
return self.__featDir
......@@ -245,14 +255,13 @@ class FEATImage(fslimage.Image):
"""Returns the COPE image for the given contrast (0-indexed). """
if self.__copes[con] is None:
copefile = featanalysis.getPEFile(self.__featDir, con)
copefile = featanalysis.getCOPEFile(self.__featDir, con)
self.__copes[con] = fslimage.Image(
copefile,
name='{}: COPE{} ({})'.format(
self.__analysisName,
con + 1,
self.contrastNames()[con]))
return self.__copes[con]
......
......@@ -986,11 +986,13 @@ class Image(Nifti):
def __del__(self):
"""Closes any open file handles, and clears some references. """
self.header = None
self.__nibImage = None
self.__imageWrapper = None
if getattr(self, '__fileobj', None) is not None:
self.__fileobj.close()
self.__fileobj = None
def getImageWrapper(self):
......
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