Skip to content

Commit

Permalink
reconstruction example
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim committed Feb 1, 2024
1 parent 0a48d78 commit 5f47a67
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/recon_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
import brkraw as br
from brkraw.lib.parser import Parameter
from brkraw.lib.pvobj import PvDatasetDir
from brkraw.lib.utils import get_value
from brkraw.lib.utils import get_value, mkdir
import brkraw as br
from brkraw.lib.recon import recon

import nibabel as nib


#PV_zipfile = "/home/jac/data/PV36034results20230630/Wilson_Tim_26171_1_Default_RAREvfl_26174_360.3.4.PvDatasets"
PV_zipfile = "/home/jac/data/nmrsu_data/Tim_Wilson_Tim_207023_1_Default_20231202FeCl3_210800_360.3.4.PvDatasets"
Expand All @@ -38,11 +40,19 @@
process = 'image'

# test functions

start_time = time.time()
data = recon(fid_binary, acqp, meth, reco, process=process)
print("{} convert {} seconds".format (process, time.time()-start_time))
data = data/np.max(np.abs(data)) # Normalize Data
#print(data.shape)

# Check if Image recontructed
output = '{}_{}'.format(data_loader._pvobj.subj_id,data_loader._pvobj.study_id)
mkdir(output)

# Reconstructed Image Matrix is always 7-dimensional
if len(data.shape) == 7:
output_fname =f"{acqp._parameters['ACQ_scan_name'].strip().replace(' ','_')}"
for c in range(data.shape[4]):
ni_img = nib.Nifti1Image(np.abs(np.squeeze(data)), affine=np.eye(4))
nib.save(ni_img, os.path.join(output,f"{acqp._parameters['ACQ_scan_name'].strip().replace(' ','_')}_C{c}.nii.gz"))
print('NifTi file is generated... [{}]'.format(output_fname))

0 comments on commit 5f47a67

Please sign in to comment.