diff --git a/fsl/data/melodiclabels.py b/fsl/data/melodiclabels.py
index 1b09858a8317b189842634ea722b248ffc38cbcd..add891dc51688a7a2a891058660526352b92b422 100644
--- a/fsl/data/melodiclabels.py
+++ b/fsl/data/melodiclabels.py
@@ -423,8 +423,10 @@ def loadLabelFile(filename, includeLabel=None, excludeLabel=None):
     else:
 
         melDir     = lines[0]
-        noisyComps = map(int, lines[-1].strip(' []').split(','))
-
+        noisyComps = lines[-1].strip(' []').split(',')
+        noisyComps = [c      for c in noisyComps if c != '']
+        noisyComps = [int(c) for c in noisyComps]
+        
         # The melodic directory path should
         # either be an absolute path, or
         # be specified relative to the location
diff --git a/fsl/utils/transform.py b/fsl/utils/transform.py
index f7bd2f21f09249500cd44fa938492e3f9b2884ce..36af95c958d0742e86885ce38da1109ffb8a3b00 100644
--- a/fsl/utils/transform.py
+++ b/fsl/utils/transform.py
@@ -20,6 +20,7 @@ spaces. The following functions are provided:
    axisAnglesToRotMat
    axisBounds
    flirtMatrixToSform
+   sformToFlirtMatrix
 """
 
 import numpy        as np
@@ -413,3 +414,32 @@ def flirtMatrixToSform(flirtMat, srcImage, refImage):
                   refInvScaledVoxelMat,
                   flirtMat,
                   srcScaledVoxelMat)
+
+
+def sformToFlirtMatrix(srcImage, refImage, srcXform=None):
+    """Under the assumption that the given ``srcImage`` and ``refImage``
+    share a common world coordinate system (defined by their
+    :attr:`voxToWorldMat` attributes), this function will calculate and
+    return a transformation matrix from the ``srcImage`` scaled voxel
+    coordinate system to the ``refImage`` scaled voxel coordinate system,
+    that can be saved to disk and used with FLIRT, to resample the source
+    image to the reference image.
+
+    :arg srcImage: Source :class:`.Image`
+    :arg refImage: Reference :class:`.Image`
+    :arg srcXform: Optionally used in place of the ``scrImage``
+                   :attr:`.voxToWorldMat`
+    """
+
+    srcScaledVoxelsToVoxelsMat = invert(srcImage.voxelsToScaledVoxels())
+    srcVoxToWorldMat           =        srcImage.voxToWorldMat
+    refWorldToVoxMat           = invert(refImage.voxToWorldMat)
+    refVoxelsToScaledVoxelsMat =        refImage.voxelsToScaledVoxels()
+
+    if srcXform is not None:
+        srcVoxToWorldMat = srcXform
+
+    return concat(refVoxelsToScaledVoxelsMat,
+                  refWorldToVoxMat,
+                  srcVoxToWorldMat,
+                  srcScaledVoxelsToVoxelsMat)