Skip to content

Commit

Permalink
update with isnr
Browse files Browse the repository at this point in the history
  • Loading branch information
ppxma7 committed Nov 21, 2023
1 parent dc5830c commit 8ce3e08
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
42 changes: 40 additions & 2 deletions fMRI_report_app/stability_app.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
function [] = stability_app(im_data,imgScale,outputBaseName)
function [] = stability_app(im_data,imgScale,outputBaseName,noise_data)
%stability_app subfunction of tSNR_app.m, part of fMRI_report_app.m
% add a plot to look at signal and std in a patch
%
% See Also tSNR_app fMRI_report_app


if ~isempty(noise_data)
runISNR = 1;
else
runISNR = 0;
end

tsnrData=mean(im_data,4)./std(im_data,0,4);

nX = size(im_data,1);
Expand All @@ -21,10 +28,18 @@

patchsize = [20 20];
xpos = round(nX./2)-15; %-20
ypos = round(nY./2); %+10
ypos = round(nY./2)-10; %+10
xpatch = xpos+patchsize(1);
ypatch = ypos+patchsize(2);


tiles= 9; % for tiles
theRound = round(nS./tiles);
sliceVec = 1:theRound:nS;
tiles = length(sliceVec);
grid = factor(length(sliceVec));
mylims = [0 2];
% BROKEN
thisSlice = round(size(cleaned_data,3).*(2./3));
%thisSlice = round(size(cleaned_data,3)./2);

Expand All @@ -35,6 +50,29 @@
patch_tSNR = mean(squatch,3)./std(squatch,0,3);
patch_tSNR_mean = mean(patch_tSNR(:));

if runISNR
%keyboard
ricianFactor = 0.66;
noise_data_corr = noise_data .* ricianFactor;
msig = mean(im_data,4);
iSNR = msig./double(noise_data_corr);
isnrfig = figure('Position',[100 100 800 600]);
tiledlayout(grid(1),grid(2))
for ii = 1:tiles
nexttile
imagesc(iSNR(:,:,sliceVec(ii)))
colormap plasma
c = colorbar;
c.Label
%c.Label.String = 'Hz';
clim([mylims(1) mylims(2)])
axis square
title(sprintf('slice %d, iSNR',sliceVec(ii)))
end
print(isnrfig,[outputBaseName '_iSNR.png'],'-dpng');

end


bloop = figure('Position',[100 100 850 500]);
tiledlayout(2,3)
Expand Down
6 changes: 5 additions & 1 deletion fMRI_report_app/tSNR_app.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@

%% send to stability app

stability_app(im_data,imgScale,outputBaseName);
if dynNOISEscan == 1
stability_app(im_data,imgScale,outputBaseName,noise_data);
else
stability_app(im_data,imgScale,outputBaseName,[]);
end


%%
Expand Down

0 comments on commit 8ce3e08

Please sign in to comment.