diff --git a/fsl/data/featanalysis.py b/fsl/data/featanalysis.py index e95ff8ae1317eeac8e8905b4c9e35aa78ee465bb..246722b576e47abb5acf9de89cc714c952e1d421 100644 --- a/fsl/data/featanalysis.py +++ b/fsl/data/featanalysis.py @@ -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)) diff --git a/fsl/data/featimage.py b/fsl/data/featimage.py index 0b37540ba55b98c6c1bf8260e01e2b279701642b..80aad19893ae4c504d2a0828e003c67134588fb0 100644 --- a/fsl/data/featimage.py +++ b/fsl/data/featimage.py @@ -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] diff --git a/fsl/data/image.py b/fsl/data/image.py index 274273f2657e8532d84c1b9fab36afa5a2d75384..0a130dcaad1169a847f5900fb27ac8f7081ee065 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -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):