diff --git a/README.md b/README.md index 0de15c1..c215ada 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/tsnr.py b/tsnr.py index 43307af..7a05e60 100755 --- a/tsnr.py +++ b/tsnr.py @@ -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: @@ -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])])