Skip to content

Commit

Permalink
More comments in tsnr.py and README
Browse files Browse the repository at this point in the history
  • Loading branch information
huawu02 committed Sep 9, 2022
1 parent a38d02b commit f513f30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Calculates the temporal SNR (tSNR) and signal fluctuation to noise ratio (SFNR)
- Gear outputs:
- tSNR map ``*_tsnr.nii.gz``, SFNR map ``*_sfnr.nii.gz``
- Plot of the temporal drift of mean signal within ROI ``*_mean_signal.png``, plot of the temporal drift of center of mass ``*_cm_drift.png``, plot of Weisskoff analysis (radius of decorrelation) ``*_rdc.png``
- JSON file ``*_results.json`` containing statistic results e.g. mean tSNR, SFNR in ROI
- JSON file ``*_results.json`` containing statistic results, e.g. mean tSNR, SFNR in ROI
- Other intermediate results

The script ``tsnr.py`` can also be executed seperately to generate tSNR maps on 4D NIFTIs containing time series images:

Expand Down
6 changes: 3 additions & 3 deletions tsnr.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
num_tpoints = noise.shape[3]
center_of_mass_t = np.zeros((3, num_tpoints))
center_of_mass_drift = np.zeros((3, num_tpoints))
# calculate the center of mass drift in mm
# calculate the center of mass drift in mm over the time series
for t in range(num_tpoints):
center_of_mass_t[:, t] = ndimage.measurements.center_of_mass(tseries[...,t])
if t == 0:
center_of_mass = list(int(s) for s in ndimage.measurements.center_of_mass(tseries[...,t]))
else:
center_of_mass_drift[:, t] = np.multiply(center_of_mass_t[:, t] - center_of_mass_t[:, 0], pixdim)
# calculate the radius of decorrelation according to the Weisskoff analysis
# calculate the radius of decorrelation according to the Weisskoff analysis. Radius of correlation measures how much correlation there is among the adjacent voxels due to noise contamination. Smaller radius of correlation indicates less contamination
roi_length = range(1, args.roi_size+1)
roi_std_detrend = []
for r in roi_length:
Expand All @@ -92,7 +92,7 @@
res = roi_mean - poly(range(num_tpoints))
roi_std_detrend.append(np.std(res))
rdc = roi_std_detrend[0] / roi_std_detrend[args.roi_size-1]
# signal intensity within ROI over the time series
# mean signal intensity within ROI over the time series. Temporal variation within 0.05% is preferred
roi_signal_mean = roi_mean
roi_signal_mean_fitted = poly(range(num_tpoints))
sfnr_center = np.mean(sfnr[np.where(roi_mask[:,:,:,0])])
Expand Down

0 comments on commit f513f30

Please sign in to comment.