Skip to content

Commit

Permalink
Added the possibility of constraining with a fat fraction dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
fsantini committed Jun 4, 2020
1 parent 6b1150d commit e15943b
Show file tree
Hide file tree
Showing 9 changed files with 779 additions and 129 deletions.
4 changes: 2 additions & 2 deletions FatFractionLookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class FatFractionLookup:
NT2s = 60 # number of calculated T2 points
NB1s = 20 # number of calculated B1 points
MagPreparePulse = False
NFF = 100
NFF = 101

def __init__(self, T2Limits, B1Limits, FatT2, NEchoes, EchoSpacing):
self.fatT2 = FatT2
Expand Down Expand Up @@ -201,7 +201,7 @@ def getAllSignals(self):
curSignalIndex += 1


return parameterCombinations, signalsOut
return np.array(parameterCombinations), signalsOut



Expand Down
5 changes: 3 additions & 2 deletions FatFractionLookup_GPU.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
from __future__ import print_function

import numpy as np
import os.path

from pycuda.autoinit import context
import pycuda.gpuarray as ga
from pycuda.compiler import SourceModule

from FatFractionLookup import calcSliceprof, reduceSliceProf, FatFractionLookup

CUDA_FILE = "epg.cu"
CUDA_FILE = os.path.join( os.path.dirname(os.path.realpath(__file__)), "epg.cu")

def getCudaFunction(nEchoes, echoSpacing, T1f, T1w, magPrep = False):
# prepare definitions
Expand Down Expand Up @@ -59,7 +60,7 @@ class FatFractionLookup_GPU(FatFractionLookup):
NT2s = 60 # number of calculated T2 points
NB1s = 20 # number of calculated B1 points
MagPreparePulse = False
NFF = 100
NFF = 101

CudaBlockSize=256 # number of threads

Expand Down
24 changes: 6 additions & 18 deletions dicomUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ def load3dDicom(path):
threeDData = None
info = []
l = os.listdir(basepath)
bar = Bar('Loading Dicom', max=100)
maxVal = len(l)
lastPercent = 0
currentFile = 0
bar = Bar('Loading Dicom', max=len(l))
threeDlist = []
for f in sorted(l):
if os.path.basename(f).startswith('.'): continue
fname, ext = os.path.splitext(f)
if ext.lower() in allowed_ext:
try:
Expand All @@ -43,10 +41,7 @@ def load3dDicom(path):
info.append(dFile)
except:
pass
currentFile += 1
if currentFile*100/maxVal > lastPercent:
bar.next()
lastPercent = currentFile*100/maxVal
bar.next()
bar.finish()
threeDData = np.stack(threeDlist, axis = 2)

Expand Down Expand Up @@ -82,10 +77,7 @@ def save3dDicom(volume, info, path, newSeriesNumber = None, newSeriesDescription
fName = os.path.join(path, "image0001.dcm") # if one wants to save a part of a dataset
dicom.write_file(fName, dicomFileData)
else:
bar = Bar('Saving Dicom', max=100)
maxVal = len(info)
lastPercent = 0
currentFile = 0
bar = Bar('Saving Dicom', max=len(info))
for sl in range(len(info)):
dataArray = volume[...,sl]
dicomFileData = copy.deepcopy(info[sl]) # create a copy of object
Expand All @@ -101,9 +93,5 @@ def save3dDicom(volume, info, path, newSeriesNumber = None, newSeriesDescription

fName = os.path.join(path, "image%04d.dcm" % (sl+startImageNumber)) # if one wants to save a part of a dataset
dicom.write_file(fName, dicomFileData)
currentFile += 1
if currentFile*100 / maxVal > lastPercent:
bar.next()
lastPercent = currentFile*100 / maxVal
bar.finish()

bar.next()
bar.finish()
2 changes: 1 addition & 1 deletion epg.cu
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ extern "C" void __global__ cpmg_sliceprof_B1_FF(unsigned int totalParameters, un
{
// calculate the cpmg signals for many values of B1 and Fat fractions
const int index = blockIdx.x*blockDim.x + threadIdx.x;
if (index > totalParameters) return;
if (index >= totalParameters) return;
float wT2 = parameters[index*3+0];
float b1 = parameters[index*3+1];
float ff = parameters[index*3+2];
Expand Down

0 comments on commit e15943b

Please sign in to comment.