Skip to content

Commit

Permalink
backprojection ready
Browse files Browse the repository at this point in the history
  • Loading branch information
pjmark committed May 8, 2024
1 parent 5b21493 commit 6956777
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 7 additions & 9 deletions niftypet/nipet/prj_inv/prj_inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,10 @@ def back_prj(sino, scanner_params, isub=ISUB_DEFAULT, dev_out=False, div_sino=No
if Cnt['SPN'] == 1:
# number of rings calculated for the given ring range
# (optionally we can use only part of the axial FOV)
NRNG_c = Cnt['RNG_END'] - Cnt['RNG_STRT']
NRNG = Cnt['RNG_END'] - Cnt['RNG_STRT']
# number of sinos in span-1
nsinos = NRNG_c**2
# correct for the max. ring difference in the full axial extent
# (don't use ring range (1,63) as for this case no correction)
if NRNG_c == 64:
nsinos -= 12
elif Cnt['SPN'] == 11:
nsinos = NRNG**2
elif Cnt['SPN'] == 3:
nsinos = Cnt['NSN11']
elif Cnt['SPN'] == 0:
nsinos = Cnt['NSEG0']
Expand All @@ -174,11 +170,13 @@ def back_prj(sino, scanner_params, isub=ISUB_DEFAULT, dev_out=False, div_sino=No
if div_sino is not None:
sino = sino[isub, :]
div_sino = cu.asarray(div_sino)

if len(sino.shape) == 3:
if sino.shape[0] != nsinos or sino.shape[1] != Cnt['NSANGLES'] or sino.shape[2] != Cnt[
'NSBINS']:
raise ValueError('Unexpected sinogram array dimensions/shape for Siemens defaults.')
sinog = mmraux.remgaps(sino, txLUT, Cnt)
sinog = sino.transpose((2,1,0))

Check failure on line 178 in niftypet/nipet/prj_inv/prj_inv.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] niftypet/nipet/prj_inv/prj_inv.py#L178

E231 missing whitespace after ','
Raw output
niftypet/nipet/prj_inv/prj_inv.py:178:34: E231 missing whitespace after ','

Check failure on line 178 in niftypet/nipet/prj_inv/prj_inv.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] niftypet/nipet/prj_inv/prj_inv.py#L178

E231 missing whitespace after ','
Raw output
niftypet/nipet/prj_inv/prj_inv.py:178:36: E231 missing whitespace after ','
sinog = sinog.reshape(Cnt['NAW'], Cnt['NSN3'])

elif len(sino.shape) == 2:
if isub[0] < 0 and sino.shape[0] != txLUT["Naw"]:
Expand Down Expand Up @@ -213,6 +211,6 @@ def back_prj(sino, scanner_params, isub=ISUB_DEFAULT, dev_out=False, div_sino=No

if not dev_out:
# > change from GPU optimised image dimensions to the standard Siemens shape
bimg = mmrimg.convert2e7(bimg, Cnt)
bimg = bimg.transpose((2,0,1))

Check failure on line 214 in niftypet/nipet/prj_inv/prj_inv.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] niftypet/nipet/prj_inv/prj_inv.py#L214

E231 missing whitespace after ','
Raw output
niftypet/nipet/prj_inv/prj_inv.py:214:33: E231 missing whitespace after ','

Check failure on line 214 in niftypet/nipet/prj_inv/prj_inv.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] niftypet/nipet/prj_inv/prj_inv.py#L214

E231 missing whitespace after ','
Raw output
niftypet/nipet/prj_inv/prj_inv.py:214:35: E231 missing whitespace after ','

return bimg
3 changes: 2 additions & 1 deletion niftypet/nipet/prj_inv/src/prjb.cu
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void gpu_bprj(float *d_im, float *d_sino, float *li2rng, short *li2sn, char *li2
nil2r_c = NLI2R;
}

// voxels in axial direction (to accounting for the variable AFOV)
// voxels in axial direction (to account for the variable AFOV)
vz0 = (int)Cnt.ZOOM * (2 * Cnt.RNG_STRT);
vz1 = (int)Cnt.ZOOM * (2 * (Cnt.RNG_END - 1));
nvz = (int)Cnt.ZOOM * (2 * nrng_c - 1);
Expand Down Expand Up @@ -328,6 +328,7 @@ void gpu_bprj(float *d_im, float *d_sino, float *li2rng, short *li2sn, char *li2

// when rings are reduced
if (nvz < SZ_IMZ) {
printf("\nw> running reduced rings procedure for the back-projected image!\n");
// number of axial row for max threads
int nar = NIPET_CU_THREADS / nvz;
dim3 THRD(nvz, nar, 1);
Expand Down

0 comments on commit 6956777

Please sign in to comment.