Skip to content

Commit 01d12ad

Browse files
committed
Further cosmetic changes
1 parent 674d1fe commit 01d12ad

File tree

5 files changed

+57
-50
lines changed

5 files changed

+57
-50
lines changed

GannetLoad.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,19 +328,19 @@
328328
% calculate the SENSE reconstruction matrix here
329329
if MRS_struct.p.PRIAM
330330
MRS_struct = senseRecon(MRS_struct);
331-
PRIAMData = zeros(length(MRS_struct.p.vox),MRS_struct.p.Navg,MRS_struct.p.npoints);
332-
PRIAMWaterData = zeros(length(MRS_struct.p.vox),MRS_struct.p.Nwateravg,MRS_struct.p.npoints);
333-
for kk = 1:MRS_struct.p.Navg
331+
PRIAMData = zeros(length(MRS_struct.p.vox), MRS_struct.p.Navg(ii), MRS_struct.p.npoints(ii));
332+
PRIAMWaterData = zeros(length(MRS_struct.p.vox), MRS_struct.p.Nwateravg(ii), MRS_struct.p.npoints(ii));
333+
for kk = 1:MRS_struct.p.Navg(ii)
334334
PRIAMData(:,kk,:) = MRS_struct.p.SENSE.U * squeeze(MRS_struct.fids.data(:,kk,:));
335335
% Phase by multiplying with normalized complex conjugate of first point
336336
conj_norm = conj(PRIAMData(:,kk,1)) ./ abs(conj(PRIAMData(:,kk,1)));
337-
PRIAMData(:,kk,:) = PRIAMData(:,kk,:) .* repmat(conj_norm, [1 1 MRS_struct.p.npoints]);
337+
PRIAMData(:,kk,:) = PRIAMData(:,kk,:) .* repmat(conj_norm, [1 1 MRS_struct.p.npoints(ii)]);
338338
end
339-
for kk = 1:MRS_struct.p.Nwateravg
339+
for kk = 1:MRS_struct.p.Nwateravg(ii)
340340
PRIAMWaterData(:,kk,:) = MRS_struct.p.SENSE.U * squeeze(MRS_struct.fids.data_water(:,kk,:));
341341
% Phase by multiplying with normalized complex conjugate of first point
342342
conj_norm = conj(PRIAMWaterData(:,kk,1)) ./ abs(conj(PRIAMWaterData(:,kk,1)));
343-
PRIAMWaterData(:,kk,:) = PRIAMWaterData(:,kk,:) .* repmat(conj_norm, [1 1 MRS_struct.p.npoints]);
343+
PRIAMWaterData(:,kk,:) = PRIAMWaterData(:,kk,:) .* repmat(conj_norm, [1 1 MRS_struct.p.npoints(ii)]);
344344
end
345345
end
346346

PhilipsDataRead_7T.m

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,33 @@
1212
% the waterdata is before loading in the GABAdata.
1313

1414
%% Read in water data -- MGSaleh 2017
15+
16+
ii = MRS_struct.ii;
17+
1518
if nargin > 2
1619
% work out data header name
1720
sparname = [fname_water(1:(end-4)) 'list'];
1821
sparheader = textscan(sparname, '%s');
1922
%ADH - decide if there is water data as ref data included in the data and
2023
%if so, set a flag to pull it out properly...
2124
sparidx=find(ismember(sparheader, 'F-resolution')==1);
22-
MRS_struct.p.npoints_water = str2double(sparheader{sparidx+2});
25+
MRS_struct.p.npoints_water(ii) = str2double(sparheader{sparidx+2});
2326
sparidx=find(ismember(sparheader, 'number_of_extra_attribute_1_values')==1);
24-
MRS_struct.p.nrows_water = str2double(sparheader{sparidx+2});
27+
MRS_struct.p.nrows_water(ii) = str2double(sparheader{sparidx+2});
2528
sparidx=find(ismember(sparheader, 'number_of_signal_averages')==1);
26-
MRS_struct.p.NSA_water(MRS_struct.ii) = str2double(sparheader{sparidx+2});
27-
MRS_struct.p.Navg_water(MRS_struct.ii) = MRS_struct.p.NSA_water(MRS_struct.ii)*MRS_struct.p.nrows_water;
29+
MRS_struct.p.NSA_water(ii) = str2double(sparheader{sparidx+2});
30+
MRS_struct.p.Navg_water(ii) = MRS_struct.p.NSA_water(ii)*MRS_struct.p.nrows_water;
2831
%Need to determine the offset of the data - i.e. how many channels are
2932
%there...
3033
sparidx=find(ismember(sparheader, 'NOI')==1);
3134
MRS_struct.p.coil_channels=size(sparidx,1)-2;
3235
sparidx=find(ismember(sparheader, 'STD')==1);
3336
MRS_struct.p.ptr_offset_water=str2double(sparheader{sparidx(3)+20});
3437

35-
MRS_struct.p.Navg_water(MRS_struct.ii) = MRS_struct.p.Navg_water(MRS_struct.ii)*MRS_struct.p.coil_channels; % MGSaleh
38+
MRS_struct.p.Navg_water(ii) = MRS_struct.p.Navg_water(ii)*MRS_struct.p.coil_channels; % MGSaleh
3639
%Need to skip rows associated with the '
3740
% [ %real/imag FID points random total_FIDS/dynamic scans dynamic scans]
38-
MRS_struct.fids.data_water = readraw_Gannet(fname_water, 'float', [2 MRS_struct.p.npoints_water 1 MRS_struct.p.Navg_water(MRS_struct.ii)/MRS_struct.p.nrows_water MRS_struct.p.nrows_water], 'l',MRS_struct.p.ptr_offset_water);
41+
MRS_struct.fids.data_water = readraw_Gannet(fname_water, 'float', [2 MRS_struct.p.npoints_water 1 MRS_struct.p.Navg_water(ii)/MRS_struct.p.nrows_water MRS_struct.p.nrows_water], 'l',MRS_struct.p.ptr_offset_water);
3942
% Make data complex.
4043
MRS_struct.fids.data_water = squeeze(complex(MRS_struct.fids.data_water(1,:,:,:,:), MRS_struct.fids.data_water(2,:,:,:,:)));
4144
FullData_water = MRS_struct.fids.data_water;
@@ -71,15 +74,15 @@
7174
sparidx=find(ismember(sparheader, 'number_of_extra_attribute_1_values')==1); %Dynamic scans
7275
MRS_struct.p.nrows = str2double(sparheader{sparidx+2});
7376
sparidx=find(ismember(sparheader, 'number_of_signal_averages')==1);
74-
MRS_struct.p.Navg(MRS_struct.ii) = str2double(sparheader{sparidx+2});
77+
MRS_struct.p.Navg(ii) = str2double(sparheader{sparidx+2});
7578
%Need to determine the offset of the data - i.e. how many channels are there...
7679
sparidx=find(ismember(sparheader, 'NOI')==1);
7780
MRS_struct.p.coil_channels=size(sparidx,1)-2;
7881
sparidx=find(ismember(sparheader, 'STD')==1);
7982
MRS_struct.p.ptr_offset=str2double(sparheader{sparidx(3)+20});
80-
MRS_struct.p.Navg_all_chann(MRS_struct.ii) = MRS_struct.p.Navg(MRS_struct.ii)*MRS_struct.p.nrows*MRS_struct.p.coil_channels; % MGSaleh
83+
MRS_struct.p.Navg_all_chann(ii) = MRS_struct.p.Navg(ii)*MRS_struct.p.nrows*MRS_struct.p.coil_channels; % MGSaleh
8184
%Need to skip rows associated with the [real/imag FID points random total_FIDS/dynamic_scans dynamic scans ]
82-
MRS_struct.fids.data = readraw_Gannet(fname, 'float', [ 2 MRS_struct.p.npoints 1 MRS_struct.p.Navg_all_chann(MRS_struct.ii)/MRS_struct.p.nrows MRS_struct.p.nrows], 'l',MRS_struct.p.ptr_offset);
85+
MRS_struct.fids.data = readraw_Gannet(fname, 'float', [ 2 MRS_struct.p.npoints 1 MRS_struct.p.Navg_all_chann(ii)/MRS_struct.p.nrows MRS_struct.p.nrows], 'l',MRS_struct.p.ptr_offset);
8386
% Make data complex.
8487
MRS_struct.fids.data = squeeze(complex(MRS_struct.fids.data(1,:,:,:,:), MRS_struct.fids.data(2,:,:,:,:)));
8588
% [ FID points coil NSA dynamic scans ]
@@ -109,7 +112,7 @@
109112
end
110113
disp('water suppressed data ... done')
111114
%I moved it to the end of the function -- MGSaleh 05252018
112-
MRS_struct.p.Navg(MRS_struct.ii) = MRS_struct.p.Navg(MRS_struct.ii)*MRS_struct.p.nrows;
115+
MRS_struct.p.Navg(ii) = MRS_struct.p.Navg(ii)*MRS_struct.p.nrows;
113116

114117
end
115118

PhilipsRawRead.m

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
%
2525
function MRS_struct = PhilipsRawRead(MRS_struct, rawfile, recon_voxel, editing)
2626

27+
ii = MRS_struct.ii;
28+
2729
% Clear previous instances
2830
signalunf = [];
2931

@@ -845,7 +847,7 @@
845847

846848
%% store images
847849
if save_images
848-
if ~(exist([rawpath filesep 'images'])==7)
850+
if ~exist([rawpath filesep 'images'],'dir')
849851
mkdir([rawpath filesep 'images']);
850852
end
851853

@@ -896,21 +898,21 @@
896898
clear a;
897899

898900
% Save all relevant data/information to MRS_struct % GO 11/01/2016
899-
MRS_struct.p.NVoxels=size(signalunf,1);
900-
MRS_struct.p.npoints = npoints; % GO 11/01/2016
901-
MRS_struct.p.nrows = size(signalunf,4); % GO 11/01/2016
902-
MRS_struct.p.ncoils = ncoils; % GO 11/01/2016
903-
MRS_struct.p.Navg = size(signalunf,4); % GO 11/01/2016
904-
MRS_struct.p.Nwateravg = nwaterfiles; % GO 11/01/2016
905-
MRS_struct.p.voxsize = [mrs_voxelsize(1) mrs_voxelsize(2) mrs_voxelsize(3)]; %AP, RL, FH - preliminary, TEST! % GO 11/01/2016
906-
MRS_struct.p.voxoff = [mrs_offset(1) mrs_offset(2) mrs_offset(3)]; %AP, RL, FH - preliminary, TEST! % GO 11/01/2016
907-
MRS_struct.p.voxang = vox_ang; % voxel angulation (1 dimension only so far) % GO 11/01/2016
908-
MRS_struct.p.TR = get_sin_TR([rawpath filesep MRSfile(1:end-4) '.sin']);% GO 11/01/2016
909-
MRS_struct.p.TE = get_sin_TE([rawpath filesep MRSfile(1:end-4) '.sin']);% GO 11/01/2016
910-
MRS_struct.p.LarmorFreq = 127; % Need to get that from somewhere! GO 11/01/2016
911-
MRS_struct.p.sw = 2e3; % Need to parse that from somewhere! GO 11/01/2016
901+
MRS_struct.p.NVoxels = size(signalunf,1);
902+
MRS_struct.p.npoints(ii) = npoints; % GO 11/01/2016
903+
MRS_struct.p.nrows(ii) = size(signalunf,4); % GO 11/01/2016
904+
MRS_struct.p.ncoils = ncoils; % GO 11/01/2016
905+
MRS_struct.p.Navg(ii) = size(signalunf,4); % GO 11/01/2016
906+
MRS_struct.p.Nwateravg(ii) = nwaterfiles; % GO 11/01/2016
907+
MRS_struct.p.voxdim(ii,:) = [mrs_voxelsize(1) mrs_voxelsize(2) mrs_voxelsize(3)]; %AP, RL, FH - preliminary, TEST! % GO 11/01/2016
908+
MRS_struct.p.voxoff(ii,:) = [mrs_offset(1) mrs_offset(2) mrs_offset(3)]; %AP, RL, FH - preliminary, TEST! % GO 11/01/2016
909+
MRS_struct.p.voxang(ii,:) = vox_ang; % voxel angulation (1 dimension only so far) % GO 11/01/2016
910+
MRS_struct.p.TR(ii) = get_sin_TR([rawpath filesep MRSfile(1:end-4) '.sin']);% GO 11/01/2016
911+
MRS_struct.p.TE(ii) = get_sin_TE([rawpath filesep MRSfile(1:end-4) '.sin']);% GO 11/01/2016
912+
MRS_struct.p.LarmorFreq(ii) = 127; % Need to get that from somewhere! GO 11/01/2016
913+
MRS_struct.p.sw(ii) = 2e3; % Need to parse that from somewhere! GO 11/01/2016
912914
MRS_struct.multivoxel.sensitivities = sensitivities; % GO 11/01/2016
913-
MRS_struct.multivoxel.voxsep = vox_sep; % voxel separation (1 dimension only so far) % GO 11/01/2016
915+
MRS_struct.multivoxel.voxsep = vox_sep; % voxel separation (1 dimension only so far) % GO 11/01/2016
914916

915917
% save all unfolded signals to MRS_struct
916918
MRS_struct.multivoxel.allsignals = signalunf; % GO 11/01/2016

SiemensDICOMRead.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
%%% DATA LOADING %%%
9292
% Preallocate array in which the FIDs are to be extracted.
93-
MRS_struct.fids.data = zeros(MRS_struct.p.npoints(ii),length(ima_file_names));
93+
MRS_struct.fids.data = zeros(MRS_struct.p.npoints(ii), length(ima_file_names));
9494

9595
% Collect all FIDs and sort them into MRS_struct
9696
for kk = 1:length(ima_file_names)

SiemensRead.m

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
function MRS_struct = SiemensRead(MRS_struct, off_filename, on_filename, water_filename)
22

3+
ii = MRS_struct.ii;
4+
35
% First load in the OFF data
46
rda_filename = off_filename;
57
fid = fopen(rda_filename);
@@ -83,30 +85,30 @@
8385

8486
%%RE 110726 Take the used bits of the header info
8587
if isfield(rda,'VOIRotationInPlane')
86-
MRS_struct.p.VoI_InPlaneRot(MRS_struct.ii) = rda.VOIRotationInPlane;
88+
MRS_struct.p.VoI_InPlaneRot(ii) = rda.VOIRotationInPlane;
8789
else
88-
MRS_struct.p.VoI_InPlaneRot(MRS_struct.ii) = 0;
90+
MRS_struct.p.VoI_InPlaneRot(ii) = 0;
8991
end
90-
MRS_struct.p.voxdim(MRS_struct.ii,1) = rda.FoVHeight;
91-
MRS_struct.p.voxdim(MRS_struct.ii,2) = rda.FoVWidth;
92-
MRS_struct.p.voxdim(MRS_struct.ii,3) = rda.SliceThickness;
93-
MRS_struct.p.voxoff(MRS_struct.ii,1) = rda.PositionVector(1);
94-
MRS_struct.p.voxoff(MRS_struct.ii,2) = rda.PositionVector(2);
95-
MRS_struct.p.voxoff(MRS_struct.ii,3) = rda.PositionVector(3);
92+
MRS_struct.p.voxdim(ii,1) = rda.FoVHeight;
93+
MRS_struct.p.voxdim(ii,2) = rda.FoVWidth;
94+
MRS_struct.p.voxdim(ii,3) = rda.SliceThickness;
95+
MRS_struct.p.voxoff(ii,1) = rda.PositionVector(1);
96+
MRS_struct.p.voxoff(ii,2) = rda.PositionVector(2);
97+
MRS_struct.p.voxoff(ii,3) = rda.PositionVector(3);
9698
if isfield(rda,'MRFrequency')
97-
MRS_struct.p.LarmorFreq(MRS_struct.ii) = rda.MRFrequency;
99+
MRS_struct.p.LarmorFreq(ii) = rda.MRFrequency;
98100
end
99101
if isfield(rda,'VectorSize')
100-
MRS_struct.p.npoints(MRS_struct.ii) = rda.VectorSize;
102+
MRS_struct.p.npoints(ii) = rda.VectorSize;
101103
end
102104
if isfield(rda,'DwellTime')
103-
MRS_struct.p.sw(MRS_struct.ii) = 1/rda.DwellTime*1E6;
105+
MRS_struct.p.sw(ii) = 1/rda.DwellTime*1E6;
104106
end
105107
if isfield(rda,'TR')
106-
MRS_struct.p.TR(MRS_struct.ii) = rda.TR;
108+
MRS_struct.p.TR(ii) = rda.TR;
107109
end
108110
if isfield(rda,'TE')
109-
MRS_struct.p.TE(MRS_struct.ii) = rda.TE;
111+
MRS_struct.p.TE(ii) = rda.TE;
110112
end
111113

112114
%
@@ -214,9 +216,9 @@
214216
end
215217

216218
%%RE 110726 Take the used bits of the header info
217-
MRS_struct.p.LarmorFreq(MRS_struct.ii) = rda.MRFrequency;
218-
MRS_struct.p.npoints(MRS_struct.ii) = rda.VectorSize;
219-
MRS_struct.p.Navg(MRS_struct.ii) = rda.NumberOfAverages;
219+
MRS_struct.p.LarmorFreq(ii) = rda.MRFrequency;
220+
MRS_struct.p.npoints(ii) = rda.VectorSize;
221+
MRS_struct.p.Navg(ii) = rda.NumberOfAverages;
220222
% So now we should have got to the point after the header text
221223
%
222224
% Siemens documentation suggests that the data should be in a double complex format (8bytes for real, and 8 for imaginary?)
@@ -322,8 +324,8 @@
322324
end
323325

324326
%%RE 110726 Take the used bits of the header info
325-
MRS_struct.p.LarmorFreq(MRS_struct.ii) = rda.MRFrequency;
326-
MRS_struct.p.npoints(MRS_struct.ii) = rda.VectorSize;
327+
MRS_struct.p.LarmorFreq(ii) = rda.MRFrequency;
328+
MRS_struct.p.npoints(ii) = rda.VectorSize;
327329
%
328330
% So now we should have got to the point after the header text
329331
%

0 commit comments

Comments
 (0)