From 6a70a75b3213253d34d0453f906ee0d1548c2892 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Thu, 11 Apr 2019 17:05:51 +0100
Subject: [PATCH] RF: Minor refactorings

---
 fsl/data/image.py | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/fsl/data/image.py b/fsl/data/image.py
index 189117fe3..19454b3a6 100644
--- a/fsl/data/image.py
+++ b/fsl/data/image.py
@@ -245,16 +245,18 @@ class Nifti(notifier.Notifier, meta.Meta):
 
         header                   = header
         origShape, shape, pixdim = Nifti.determineShape(header)
+        voxToWorldMat            = Nifti.determineAffine(header)
+        affines, isneuro         = Nifti.generateAffines(voxToWorldMat,
+                                                         shape,
+                                                         pixdim)
 
-        self.header      = header
-        self.__shape     = shape
-        self.__origShape = origShape
-        self.__pixdim    = pixdim
-        self.__intent    = header.get('intent_code',
-                                      constants.NIFTI_INTENT_NONE)
 
-        voxToWorldMat    = Nifti.determineAffine(header)
-        affines, isneuro = Nifti.generateAffines(voxToWorldMat, shape, pixdim)
+        self.header           = header
+        self.__shape          = shape
+        self.__origShape      = origShape
+        self.__pixdim         = pixdim
+        self.__intent         = header.get('intent_code',
+                                           constants.NIFTI_INTENT_NONE)
 
         self.__affines        = affines
         self.__isNeurological = isneuro
@@ -1206,7 +1208,9 @@ class Image(Nifti):
         # We save the image out to a temp file,
         # then close the old image, move the
         # temp file to the real destination,
-        # then re-open the file.
+        # then re-open the file. This is done
+        # to ensure that all references to the
+        # old file are destroyed.
         tmphd, tmpfname = tempfile.mkstemp(suffix=getExt(filename))
         os.close(tmphd)
 
-- 
GitLab