Skip to content

Commit

Permalink
untouch
Browse files Browse the repository at this point in the history
  • Loading branch information
scott committed Apr 27, 2017
1 parent 53dd9a4 commit 4761ba0
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 40 deletions.
6 changes: 3 additions & 3 deletions getBP_VOI.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
subj = subj(1:5); % should remove this hard coding!!!

%%% load VOI image %%%
VOI_struct = load_nii([svca4.outputPath '/roiMasks/' subj '_thalamus.nii.gz']);
VOI_struct = load_untouch_nii([svca4.outputPath '/roiMasks/' subj '_thalamus.nii.gz']);
VOI = single(VOI_struct.img);
indVOI = find(VOI==1);

BPc_struct = load_nii([svca4.outputPath '/petData_quantif/interfile_' subj '_pet_flip_CEREBa2_BPnd_SRTM2.nii']);
BPc_struct = load_untouch_nii([svca4.outputPath '/petData_quantif/interfile_' subj '_pet_flip_CEREBa2_BPnd_SRTM2.nii']);
BPc = single(BPc_struct.img);
thalBPc(s) = mean(BPc(indVOI));

BPs_struct = load_nii([svca4.outputPath '/petData_quantif/interfile_' subj '_pet_flip_SVCAa2_BPnd_SRTM2.nii']);
BPs_struct = load_untouch_nii([svca4.outputPath '/petData_quantif/interfile_' subj '_pet_flip_SVCAa2_BPnd_SRTM2.nii']);
BPs = single(BPs_struct.img);
thalBPs(s) = mean(BPs(indVOI));
end
Expand Down
4 changes: 2 additions & 2 deletions getVOIvals.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
subj = subj(1:5); % should remove this hard coding!!!

%%% load PET image %%%
PET_struct = load_nii(fullfile(svca4.PET_dir, svca4.PET_list{s}));
PET_struct = load_untouch_nii(fullfile(svca4.PET_dir, svca4.PET_list{s}));
PET = single(PET_struct.img);
svca4.Res = PET_struct.hdr.dime.pixdim([2 4 3]); %
xDim = size(PET,1);
yDim = size(PET,2);
zDim = size(PET,3);

%%% load VOI image %%%
VOI_struct = load_nii([svca4.outputPath '/roiMasks/' subj '_thalamus.nii.gz']);
VOI_struct = load_untouch_nii([svca4.outputPath '/roiMasks/' subj '_thalamus.nii.gz']);
VOI = single(VOI_struct.img);
indVOI = find(VOI==1);

Expand Down
34 changes: 32 additions & 2 deletions justForFun.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,39 @@
gmwm_files = dir('/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/gmwm/*_2pet*' );
brain_files = dir('/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/roiMasks/*_brainMask*' );

load('/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_thals/svca4_thals.mat', 'svca4')
xt = svca4.PET_standardEndTimes; clear svca4;

Nrand = [.1 .5 1 10];
Nboots = 10;
Output = zeros(numel(Nrand),Nboots,31,length(pet_files));
for s = 1%:length(pet_files)
%%% load pet image %%%
PET_struct = load_nii(pet_files(s));
PET = single(TARGET_struct.img);
PET_struct = load_untouch_nii(['/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/data_pet/' pet_files(s).name]);
PET = single(PET_struct.img);

%%% load brain mask %%%
% BRAIN_struct = load_untouch_nii(['/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/roiMasks/' brain_files(s).name]);
% BRAIN = single(BRAIN_struct.img);
% indBRAIN = find(BRAIN==1);

%%% load Grey mask %%%
GM_struct = load_untouch_nii(['/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/gmwm/' gmwm_files(s).name]);
GM = single(GM_struct.img);
indGM = find(GM==1);

for n = 1:numel(Nrand)
for b = 1:Nboots
randInds = randperm(numel(indGM),round(numel(indGM)*Nrand(n)/100));
for t=1:31
PET_t=PET(:,:,:,t);
TEMP = GM(indGM(randInds)).*PET_t(indGM(randInds));
GRAYt(t) = sum(TEMP(:));
end
GRAYt(s,:) = GRAYt(:)/numel(randInds);
Output(n,b,:,s) = GRAYt;
end
end
end

%%
2 changes: 1 addition & 1 deletion svca4_ClassGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function svca4_ClassGui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = varargin{1};

% change max frame dropdown
tmp = load_nii_hdr(fullfile(handles.output.PET_dir,handles.output.PET_list{1}));
tmp = load_untouch_header_only(fullfile(handles.output.PET_dir,handles.output.PET_list{1}));
handles.max_frame.String = 1:tmp.dime.dim(5);
handles.max_frame.Value = handles.output.nFrames;

Expand Down
4 changes: 2 additions & 2 deletions svca4_bpVoi.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
bpf = bp_list{ind};

%%% load all BP image %%%
BP_struct = load_nii([bp_dir bpf]);
BP_struct = load_untouch_nii([bp_dir bpf]);
BP = single(BP_struct.img);

%%% load all VOIs %%%
VOI_struct = load_nii([svca4.SUBJECTS_DIR filesep subj filesep 'label' filesep subj '_AparcAseg_in_PET.nii.gz']);
VOI_struct = load_untouch_nii([svca4.SUBJECTS_DIR filesep subj filesep 'label' filesep subj '_AparcAseg_in_PET.nii.gz']);
VOI = single(VOI_struct.img);
VOInums = unique(VOI);
VOInums = VOInums(VOInums > 0);
Expand Down
14 changes: 7 additions & 7 deletions svca4_extractRefGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,21 @@ function extract_Callback(hObject, eventdata, handles)

% load the brain mask
mname = fullfile(svca4.MASK_dir,svca4.MASK_list{inds(s)});
MASK_struct = load_nii(mname);
MASK_struct = load_untouch_nii(mname);
MASK = single(MASK_struct.img);
clear MASK_struct

if handles.remCereb.Value == 1
CB = fullfile(svca4.outputPath, 'roiMasks', [svca4.Names{inds(s)} '_' 'cerebellum_grey.nii.gz']);
% load the brain mask
CB_struct = load_nii(CB);
CB_struct = load_untouch_nii(CB);
CB_mask = single(CB_struct.img);
clear CB_struct
MASK = MASK-CB_mask;
end

pname = fullfile(svca4.PET_dir,svca4.PET_list{inds(s)});
PET_struct = load_nii(pname);
PET_struct = load_untouch_nii(pname);
PET = single(PET_struct.img);
xDim = size(PET,1);
yDim = size(PET,2);
Expand All @@ -127,28 +127,28 @@ function extract_Callback(hObject, eventdata, handles)
fname = sprintf('%s/weights/%s_GRAY_it%.2d.nii', svca4.outputPath, svca4.Names{inds(s)}, ifeedback);
else fname = sprintf('%s/weights/%s_GRAY_q%d_it%.2d.nii', svca4.outputPath, svca4.Names{inds(s)}, q*100,ifeedback);
end
GRAY = load_nii(fname);
GRAY = load_untouch_nii(fname);
GRAY = GRAY.img;

if ifeedback == 0
fname = sprintf('%s/weights/%s_WHITE_it%.2d.nii', svca4.outputPath, svca4.Names{inds(s)}, ifeedback);
else fname = sprintf('%s/weights/%s_WHITE_q%d_it%.2d.nii', svca4.outputPath, svca4.Names{inds(s)}, q*100,ifeedback);
end
WHITE = load_nii(fname);
WHITE = load_untouch_nii(fname);
WHITE = WHITE.img;

if ifeedback == 0
fname = sprintf('%s/weights/%s_BLOOD_it%.2d.nii', svca4.outputPath, svca4.Names{inds(s)}, ifeedback);
else fname = sprintf('%s/weights/%s_BLOOD_q%d_it%.2d.nii', svca4.outputPath, svca4.Names{inds(s)}, q*100,ifeedback);
end
BLOOD = load_nii(fname);
BLOOD = load_untouch_nii(fname);
BLOOD = BLOOD.img;

if ifeedback == 0
fname = sprintf('%s/weights/%s_TSPO_it%.2d.nii', svca4.outputPath, svca4.Names{inds(s)}, ifeedback);
else fname = sprintf('%s/weights/%s_TSPO_q%d_it%.2d.nii', svca4.outputPath, svca4.Names{inds(s)}, q*100,ifeedback);
end
TSPO = load_nii(fname);
TSPO = load_untouch_nii(fname);
TSPO = TSPO.img;

% ----------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions svca4_imageTACGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ function create_Callback(hObject, eventdata, handles)
%handles.petF{1}
%handles.imageF{1}
%%% load PET image %%%
PET_struct = load_nii(handles.petF{1});
PET_struct = load_untouch_nii(handles.petF{1});
PET = single(PET_struct.img);

%%% load mask %%%
MASK_struct = load_nii(handles.imageF{1});
MASK_struct = load_untouch_nii(handles.imageF{1});
MASK = single(MASK_struct.img);

%%% if the image is not binary threshold at 95% %%%
Expand Down
16 changes: 8 additions & 8 deletions svca4_iterateGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ function iterate_Callback(hObject, eventdata, handles)

for fi=svca4.classIDs % for each target subject
%%% load brain mask %%%
MASK_struct = load_nii(fullfile(svca4.MASK_dir, svca4.MASK_list{fi}));
MASK_struct = load_untouch_nii(fullfile(svca4.MASK_dir, svca4.MASK_list{fi}));
MASK = single(MASK_struct.img);
clear MASK_struct

%%% load PET image %%%
PET_struct = load_nii(fullfile(svca4.PET_dir, svca4.PET_list{fi}));
PET_struct = load_untouch_nii(fullfile(svca4.PET_dir, svca4.PET_list{fi}));
PET = single(PET_struct.img);
svca4.Res = PET_struct.hdr.dime.pixdim([2 4 3]); %
xDim = size(PET,1);
Expand All @@ -141,7 +141,7 @@ function iterate_Callback(hObject, eventdata, handles)
fname = sprintf('%s/weights/%s_BLOOD_it%.2d.nii', svca4.outputPath, svca4.Names{fi}, ifeedback);
else fname = sprintf('%s/weights/%s_BLOOD_q%d_it%.2d.nii', svca4.outputPath, svca4.Names{fi}, q*100,ifeedback);
end
BLOOD = load_nii(fname);
BLOOD = load_untouch_nii(fname);
BLOOD = BLOOD.img;
BLOOD = BLOOD.*MASK;
quant_BLOOD = quantile(BLOOD(BLOOD~=0),q);
Expand Down Expand Up @@ -169,7 +169,7 @@ function iterate_Callback(hObject, eventdata, handles)
fname = sprintf('%s/weights/%s_GRAY_it%.2d.nii', svca4.outputPath, svca4.Names{fi}, ifeedback);
else fname = sprintf('%s/weights/%s_GRAY_q%d_it%.2d.nii', svca4.outputPath, svca4.Names{fi}, q*100,ifeedback);
end
GRAY = load_nii(fname);
GRAY = load_untouch_nii(fname);
GRAY = GRAY.img;
GRAY = GRAY.*MASK;
quant_GRAY = quantile(GRAY(GRAY~=0),q);
Expand All @@ -180,7 +180,7 @@ function iterate_Callback(hObject, eventdata, handles)
fname = sprintf('%s/weights/%s_WHITE_it%.2d.nii', svca4.outputPath, svca4.Names{fi}, ifeedback);
else fname = sprintf('%s/weights/%s_WHITE_q%d_it%.2d.nii', svca4.outputPath, svca4.Names{fi}, q*100,ifeedback);
end
WHITE = load_nii(fname);
WHITE = load_untouch_nii(fname);
WHITE = WHITE.img;
WHITE = WHITE.*MASK;
quant_WHITE = quantile(WHITE(WHITE~=0),q);
Expand All @@ -204,7 +204,7 @@ function iterate_Callback(hObject, eventdata, handles)
fname = sprintf('%s/weights/%s_TSPO_it%.2d.nii', svca4.outputPath, svca4.Names{fi}, ifeedback);
else fname = sprintf('%s/weights/%s_TSPO_q%d_it%.2d.nii', svca4.outputPath, svca4.Names{fi}, q*100,ifeedback);
end
TSPO = load_nii(fname);
TSPO = load_untouch_nii(fname);
TSPO = TSPO.img;
TSPO = TSPO.*MASK;
quant_TSPO = quantile(TSPO(TSPO~=0),q);
Expand Down Expand Up @@ -253,12 +253,12 @@ function iterate_Callback(hObject, eventdata, handles)
CLASS(isnan(CLASS)) = 0; % this might not be the best approach but the regression cannot have NaNs

%%% load brain mask %%%
MASK_struct = load_nii(fullfile(svca4.MASK_dir, svca4.MASK_list{fi}));
MASK_struct = load_untouch_nii(fullfile(svca4.MASK_dir, svca4.MASK_list{fi}));
MASK = single(MASK_struct.img);
clear MASK_struct

%%% load target image %%%
TARGET_struct = load_nii(fullfile(svca4.PET_dir, svca4.PET_list{fi}));
TARGET_struct = load_untouch_nii(fullfile(svca4.PET_dir, svca4.PET_list{fi}));
TARGET = single(TARGET_struct.img);
xDim = size(TARGET,1);
yDim = size(TARGET,2);
Expand Down
8 changes: 4 additions & 4 deletions svca4_mainGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ function cereb_ref_Callback(hObject, eventdata, handles)

CB = fullfile(svca4.outputPath, 'roiMasks', [svca4.Names{s} '_' 'cerebellum_grey.nii.gz']);
% load the brain mask
CB_struct = load_nii(CB);
CB_struct = load_untouch_nii(CB);
CB_mask = single(CB_struct.img);
clear CB_struct

pname = fullfile(svca4.PET_dir,svca4.PET_list{s});
PET_struct = load_nii(pname);
PET_struct = load_untouch_nii(pname);
PET = single(PET_struct.img);
xDim = size(PET,1);
yDim = size(PET,2);
Expand Down Expand Up @@ -302,11 +302,11 @@ function bp_voi_Callback(hObject, eventdata, handles)
bpf = bp_list{ind};

%%% load all BP image %%%
BP_struct = load_nii(bpf);
BP_struct = load_untouch_nii(bpf);
BP = single(BP_struct.img);

%%% load all VOIs %%%
VOI_struct = load_nii([svca4.SUBJECTS_DIR filesep subj filesep 'label' filesep subj '_AparcAseg_in_PET.nii.gz']);
VOI_struct = load_untouch_nii([svca4.SUBJECTS_DIR filesep subj filesep 'label' filesep subj '_AparcAseg_in_PET.nii.gz']);
VOI = single(VOI_struct.img);
VOInums = unique(VOI);
VOInums = VOInums(VOInums > 0);
Expand Down
8 changes: 4 additions & 4 deletions svca4_timeShiftGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ function shift_Callback(hObject, eventdata, handles)

% load the brain mask
mname = fullfile(svca4.MASK_dir,svca4.MASK_list{inds(s)});
MASK_struct = load_nii(mname);
MASK_struct = load_untouch_nii(mname);
MASK = single(MASK_struct.img);
clear MASK_struct

pname = fullfile(svca4.PET_dir,svca4.PET_list{inds(s)});
PET_struct = load_nii(pname);
PET_struct = load_untouch_nii(pname);
PET = single(PET_struct.img);
xDim = size(PET,1);
yDim = size(PET,2);
Expand All @@ -133,7 +133,7 @@ function shift_Callback(hObject, eventdata, handles)

% load the blood mask
bname = fullfile(svca4.BANANA_dir, svca4.BANANA_list{inds(s)});
BANANA_struct = load_nii(bname);
BANANA_struct = load_untouch_nii(bname);
BANANA = single(BANANA_struct.img);
BM4D = single(repmat(BANANA, [1 1 1 numel(svca4.BLOOD_frames)]));
clear BANANA_struct
Expand Down Expand Up @@ -196,5 +196,5 @@ function shift_Callback(hObject, eventdata, handles)
% save the normalized and shifted dynamic PET data
oname = fullfile(svca4.PET_dir, [svca4.PET_list{inds(s)}(1:end-4) '_norm_shift_' num2str(peak_diff) '.nii']);
PET_struct.img = single(flip(PET_shift));
%save_nii(PET_struct, oname)
%save_untouch_nii(PET_struct, oname)
end
6 changes: 3 additions & 3 deletions svca4_voiTACGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ function create_TAC_Callback(hObject, eventdata, handles)
for s = 1:length(handles.subs.Value) % loop on subjects

%%% load segmentation image %%%
SEG_struct = load_nii(fullfile(svca4.SUBJECTS_DIR, subj{s}, 'label', [subj{s} '_AparcAseg_in_PET.nii.gz']));
SEG_struct = load_untouch_nii(fullfile(svca4.SUBJECTS_DIR, subj{s}, 'label', [subj{s} '_AparcAseg_in_PET.nii.gz']));
SEG = single(SEG_struct.img);
clear SEG_Struct
indsVOI = ismember(SEG,voiNums);
%%% load PET image %%%
PET_struct = load_nii(fullfile(svca4.PET_dir, svca4.PET_list{s}));
PET_struct = load_untouch_nii(fullfile(svca4.PET_dir, svca4.PET_list{s}));
PET = single(PET_struct.img);
svca4.Res = PET_struct.hdr.dime.pixdim([2 4 3]); %
xDim = size(PET,1);
Expand All @@ -173,7 +173,7 @@ function create_TAC_Callback(hObject, eventdata, handles)
end
case 1
%%% load brain mask %%%
MASK_struct = load_nii(fullfile(svca4.MASK_dir, svca4.MASK_list{s}));
MASK_struct = load_untouch_nii(fullfile(svca4.MASK_dir, svca4.MASK_list{s}));
MASK = single(MASK_struct.img);
clear MASK_struct

Expand Down
4 changes: 2 additions & 2 deletions unNormCLASSES.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
for fi = 1:numel(svca4.PET_list)

%%% load brain mask %%%
MASK_struct = load_nii(fullfile(svca4.MASK_dir, svca4.MASK_list{fi}));
MASK_struct = load_untouch_nii(fullfile(svca4.MASK_dir, svca4.MASK_list{fi}));
MASK = single(MASK_struct.img);
%clear MASK_struct

%%% load PET image %%%
PET_struct = load_nii(fullfile(svca4.PET_dir, svca4.PET_list{fi}));
PET_struct = load_untouch_nii(fullfile(svca4.PET_dir, svca4.PET_list{fi}));
PET = single(PET_struct.img);
svca4.Res = PET_struct.hdr.dime.pixdim([2 4 3]); %
xDim = size(PET,1);
Expand Down

0 comments on commit 4761ba0

Please sign in to comment.