docs: function NIfTIToNRRD(niftiHeader) {
    var ret = {}
    ret.dimension = niftiHeader.dim[0]
    ret.type = niftiHeader.datatype // TODO: Check that we do not feed anything incompatible?
    ret.encoding = 'raw'
    ret.endian = niftiHeader.littleEndian ? 'little' : 'big'
    ret.sizes = niftiHeader.dim.slice(1) // Note that both NRRD and NIfTI use the convention that the fastest axis comes first!
    ret.thicknesses=niftiHeader.pixdim.slice(1);
  
    if (niftiHeader.xyzt_units !== undefined) {
      ret.spaceUnits = niftiHeader.xyzt_units
      while(ret.spaceUnits.length < ret.dimension) { // Pad if necessary
        ret.spaceUnits.push("")
      }
      ret.spaceUnits.length = ret.dimension // Shrink if necessary
    }
    
    if (niftiHeader.qform_code === 0) { // "method 1"
      ret.spacings = niftiHeader.pixdim.slice(1)
      while(ret.spacings.length < ret.dimension) {
        ret.spacings.push(NaN)
      }
      ret.spaceDimension = Math.min(ret.dimension, 3) // There might be non-3D data sets? (Although the NIfTI format does seem /heavily/ reliant on assuming a 3D space.)
    } else if (niftiHeader.qform_code > 0) { // "method 2"
      // TODO: Figure out exactly what to do with the different qform codes.
      ret.space = "right-anterior-superior" // Any method for orientation (except for "method 1") uses this, apparently.
      var qfac = niftiHeader.pixdim[0] === 0.0 ? 1 : niftiHeader.pixdim[0]
      var a = Math.sqrt(Math.max(0.0,1.0-(niftiHeader.quatern_b*niftiHeader.quatern_b + niftiHeader.quatern_c*niftiHeader.quatern_c + niftiHeader.quatern_d*niftiHeader.quatern_d)))
      var b = niftiHeader.quatern_b
      var c = niftiHeader.quatern_c
      var d = niftiHeader.quatern_d
      ret.spaceDirections = [
        [niftiHeader.pixdim[1]*(a*a+b*b-c*c-d*d),niftiHeader.pixdim[1]*(2*b*c+2*a*d),niftiHeader.pixdim[1]*(2*b*d-2*a*c)],
        [niftiHeader.pixdim[2]*(2*b*c-2*a*d),niftiHeader.pixdim[2]*(a*a+c*c-b*b-d*d),niftiHeader.pixdim[2]*(2*c*d+2*a*b)],
        [qfac*niftiHeader.pixdim[3]*(2*b*d+2*a*c),qfac*niftiHeader.pixdim[3]*(2*c*d-2*a*b),qfac*niftiHeader.pixdim[3]*(a*a+d*d-c*c-b*b)]]
      ret.spaceOrigin = [niftiHeader.qoffset_x,niftiHeader.qoffset_y,niftiHeader.qoffset_z]
    } else {
      console.warn("Invalid qform_code: " + niftiHeader.qform_code + ", orientation is probably messed up.")
    }
    // TODO: Here we run into trouble, because in NRRD we cannot expose two DIFFERENT (not complementary, different!) transformations. Even more frustrating is that sform transformations are actually more compatible with NRRD than the qform methods.
    if (niftiHeader.sform_code > 0) {
      console.warn("sform transformation are currently ignored.")
    }
    /*if (niftiHeader.sform_code > 0) { // "method 3"
      ret.space = "right-anterior-superior" // Any method for orientation (except for "method 1") uses this, apparently.
      ret.spaceDirections = [
        [niftiHeader.srow[0*4 + 0],niftiHeader.srow[1*4 + 0],niftiHeader.srow[2*4 + 0]],
        [niftiHeader.srow[0*4 + 1],niftiHeader.srow[1*4 + 1],niftiHeader.srow[2*4 + 1]],
        [niftiHeader.srow[0*4 + 2],niftiHeader.srow[1*4 + 2],niftiHeader.srow[2*4 + 2]]]
      ret.spaceOrigin = [niftiHeader.srow[0*4 + 3],niftiHeader.srow[1*4 + 3],niftiHeader.srow[2*4 + 3]]
    }*/
    // TODO: Enforce that spaceDirections and so on have the correct size.
    
    // TODO: We're still missing an awful lot of info!
    
    return ret
  }