Skip to content

Commit

Permalink
Further cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
markmikkelsen committed Mar 14, 2023
1 parent 674d1fe commit 01d12ad
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 50 deletions.
12 changes: 6 additions & 6 deletions GannetLoad.m
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,19 @@
% calculate the SENSE reconstruction matrix here
if MRS_struct.p.PRIAM
MRS_struct = senseRecon(MRS_struct);
PRIAMData = zeros(length(MRS_struct.p.vox),MRS_struct.p.Navg,MRS_struct.p.npoints);
PRIAMWaterData = zeros(length(MRS_struct.p.vox),MRS_struct.p.Nwateravg,MRS_struct.p.npoints);
for kk = 1:MRS_struct.p.Navg
PRIAMData = zeros(length(MRS_struct.p.vox), MRS_struct.p.Navg(ii), MRS_struct.p.npoints(ii));
PRIAMWaterData = zeros(length(MRS_struct.p.vox), MRS_struct.p.Nwateravg(ii), MRS_struct.p.npoints(ii));
for kk = 1:MRS_struct.p.Navg(ii)
PRIAMData(:,kk,:) = MRS_struct.p.SENSE.U * squeeze(MRS_struct.fids.data(:,kk,:));
% Phase by multiplying with normalized complex conjugate of first point
conj_norm = conj(PRIAMData(:,kk,1)) ./ abs(conj(PRIAMData(:,kk,1)));
PRIAMData(:,kk,:) = PRIAMData(:,kk,:) .* repmat(conj_norm, [1 1 MRS_struct.p.npoints]);
PRIAMData(:,kk,:) = PRIAMData(:,kk,:) .* repmat(conj_norm, [1 1 MRS_struct.p.npoints(ii)]);
end
for kk = 1:MRS_struct.p.Nwateravg
for kk = 1:MRS_struct.p.Nwateravg(ii)
PRIAMWaterData(:,kk,:) = MRS_struct.p.SENSE.U * squeeze(MRS_struct.fids.data_water(:,kk,:));
% Phase by multiplying with normalized complex conjugate of first point
conj_norm = conj(PRIAMWaterData(:,kk,1)) ./ abs(conj(PRIAMWaterData(:,kk,1)));
PRIAMWaterData(:,kk,:) = PRIAMWaterData(:,kk,:) .* repmat(conj_norm, [1 1 MRS_struct.p.npoints]);
PRIAMWaterData(:,kk,:) = PRIAMWaterData(:,kk,:) .* repmat(conj_norm, [1 1 MRS_struct.p.npoints(ii)]);
end
end

Expand Down
23 changes: 13 additions & 10 deletions PhilipsDataRead_7T.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,33 @@
% the waterdata is before loading in the GABAdata.

%% Read in water data -- MGSaleh 2017

ii = MRS_struct.ii;

if nargin > 2
% work out data header name
sparname = [fname_water(1:(end-4)) 'list'];
sparheader = textscan(sparname, '%s');
%ADH - decide if there is water data as ref data included in the data and
%if so, set a flag to pull it out properly...
sparidx=find(ismember(sparheader, 'F-resolution')==1);
MRS_struct.p.npoints_water = str2double(sparheader{sparidx+2});
MRS_struct.p.npoints_water(ii) = str2double(sparheader{sparidx+2});
sparidx=find(ismember(sparheader, 'number_of_extra_attribute_1_values')==1);
MRS_struct.p.nrows_water = str2double(sparheader{sparidx+2});
MRS_struct.p.nrows_water(ii) = str2double(sparheader{sparidx+2});
sparidx=find(ismember(sparheader, 'number_of_signal_averages')==1);
MRS_struct.p.NSA_water(MRS_struct.ii) = str2double(sparheader{sparidx+2});
MRS_struct.p.Navg_water(MRS_struct.ii) = MRS_struct.p.NSA_water(MRS_struct.ii)*MRS_struct.p.nrows_water;
MRS_struct.p.NSA_water(ii) = str2double(sparheader{sparidx+2});
MRS_struct.p.Navg_water(ii) = MRS_struct.p.NSA_water(ii)*MRS_struct.p.nrows_water;
%Need to determine the offset of the data - i.e. how many channels are
%there...
sparidx=find(ismember(sparheader, 'NOI')==1);
MRS_struct.p.coil_channels=size(sparidx,1)-2;
sparidx=find(ismember(sparheader, 'STD')==1);
MRS_struct.p.ptr_offset_water=str2double(sparheader{sparidx(3)+20});

MRS_struct.p.Navg_water(MRS_struct.ii) = MRS_struct.p.Navg_water(MRS_struct.ii)*MRS_struct.p.coil_channels; % MGSaleh
MRS_struct.p.Navg_water(ii) = MRS_struct.p.Navg_water(ii)*MRS_struct.p.coil_channels; % MGSaleh
%Need to skip rows associated with the '
% [ %real/imag FID points random total_FIDS/dynamic scans dynamic scans]
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);
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);
% Make data complex.
MRS_struct.fids.data_water = squeeze(complex(MRS_struct.fids.data_water(1,:,:,:,:), MRS_struct.fids.data_water(2,:,:,:,:)));
FullData_water = MRS_struct.fids.data_water;
Expand Down Expand Up @@ -71,15 +74,15 @@
sparidx=find(ismember(sparheader, 'number_of_extra_attribute_1_values')==1); %Dynamic scans
MRS_struct.p.nrows = str2double(sparheader{sparidx+2});
sparidx=find(ismember(sparheader, 'number_of_signal_averages')==1);
MRS_struct.p.Navg(MRS_struct.ii) = str2double(sparheader{sparidx+2});
MRS_struct.p.Navg(ii) = str2double(sparheader{sparidx+2});
%Need to determine the offset of the data - i.e. how many channels are there...
sparidx=find(ismember(sparheader, 'NOI')==1);
MRS_struct.p.coil_channels=size(sparidx,1)-2;
sparidx=find(ismember(sparheader, 'STD')==1);
MRS_struct.p.ptr_offset=str2double(sparheader{sparidx(3)+20});
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
MRS_struct.p.Navg_all_chann(ii) = MRS_struct.p.Navg(ii)*MRS_struct.p.nrows*MRS_struct.p.coil_channels; % MGSaleh
%Need to skip rows associated with the [real/imag FID points random total_FIDS/dynamic_scans dynamic scans ]
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);
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);
% Make data complex.
MRS_struct.fids.data = squeeze(complex(MRS_struct.fids.data(1,:,:,:,:), MRS_struct.fids.data(2,:,:,:,:)));
% [ FID points coil NSA dynamic scans ]
Expand Down Expand Up @@ -109,7 +112,7 @@
end
disp('water suppressed data ... done')
%I moved it to the end of the function -- MGSaleh 05252018
MRS_struct.p.Navg(MRS_struct.ii) = MRS_struct.p.Navg(MRS_struct.ii)*MRS_struct.p.nrows;
MRS_struct.p.Navg(ii) = MRS_struct.p.Navg(ii)*MRS_struct.p.nrows;

end

32 changes: 17 additions & 15 deletions PhilipsRawRead.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
%
function MRS_struct = PhilipsRawRead(MRS_struct, rawfile, recon_voxel, editing)

ii = MRS_struct.ii;

% Clear previous instances
signalunf = [];

Expand Down Expand Up @@ -845,7 +847,7 @@

%% store images
if save_images
if ~(exist([rawpath filesep 'images'])==7)
if ~exist([rawpath filesep 'images'],'dir')
mkdir([rawpath filesep 'images']);
end

Expand Down Expand Up @@ -896,21 +898,21 @@
clear a;

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

% save all unfolded signals to MRS_struct
MRS_struct.multivoxel.allsignals = signalunf; % GO 11/01/2016
Expand Down
2 changes: 1 addition & 1 deletion SiemensDICOMRead.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

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

% Collect all FIDs and sort them into MRS_struct
for kk = 1:length(ima_file_names)
Expand Down
38 changes: 20 additions & 18 deletions SiemensRead.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function MRS_struct = SiemensRead(MRS_struct, off_filename, on_filename, water_filename)

ii = MRS_struct.ii;

% First load in the OFF data
rda_filename = off_filename;
fid = fopen(rda_filename);
Expand Down Expand Up @@ -83,30 +85,30 @@

%%RE 110726 Take the used bits of the header info
if isfield(rda,'VOIRotationInPlane')
MRS_struct.p.VoI_InPlaneRot(MRS_struct.ii) = rda.VOIRotationInPlane;
MRS_struct.p.VoI_InPlaneRot(ii) = rda.VOIRotationInPlane;
else
MRS_struct.p.VoI_InPlaneRot(MRS_struct.ii) = 0;
MRS_struct.p.VoI_InPlaneRot(ii) = 0;
end
MRS_struct.p.voxdim(MRS_struct.ii,1) = rda.FoVHeight;
MRS_struct.p.voxdim(MRS_struct.ii,2) = rda.FoVWidth;
MRS_struct.p.voxdim(MRS_struct.ii,3) = rda.SliceThickness;
MRS_struct.p.voxoff(MRS_struct.ii,1) = rda.PositionVector(1);
MRS_struct.p.voxoff(MRS_struct.ii,2) = rda.PositionVector(2);
MRS_struct.p.voxoff(MRS_struct.ii,3) = rda.PositionVector(3);
MRS_struct.p.voxdim(ii,1) = rda.FoVHeight;
MRS_struct.p.voxdim(ii,2) = rda.FoVWidth;
MRS_struct.p.voxdim(ii,3) = rda.SliceThickness;
MRS_struct.p.voxoff(ii,1) = rda.PositionVector(1);
MRS_struct.p.voxoff(ii,2) = rda.PositionVector(2);
MRS_struct.p.voxoff(ii,3) = rda.PositionVector(3);
if isfield(rda,'MRFrequency')
MRS_struct.p.LarmorFreq(MRS_struct.ii) = rda.MRFrequency;
MRS_struct.p.LarmorFreq(ii) = rda.MRFrequency;
end
if isfield(rda,'VectorSize')
MRS_struct.p.npoints(MRS_struct.ii) = rda.VectorSize;
MRS_struct.p.npoints(ii) = rda.VectorSize;
end
if isfield(rda,'DwellTime')
MRS_struct.p.sw(MRS_struct.ii) = 1/rda.DwellTime*1E6;
MRS_struct.p.sw(ii) = 1/rda.DwellTime*1E6;
end
if isfield(rda,'TR')
MRS_struct.p.TR(MRS_struct.ii) = rda.TR;
MRS_struct.p.TR(ii) = rda.TR;
end
if isfield(rda,'TE')
MRS_struct.p.TE(MRS_struct.ii) = rda.TE;
MRS_struct.p.TE(ii) = rda.TE;
end

%
Expand Down Expand Up @@ -214,9 +216,9 @@
end

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

%%RE 110726 Take the used bits of the header info
MRS_struct.p.LarmorFreq(MRS_struct.ii) = rda.MRFrequency;
MRS_struct.p.npoints(MRS_struct.ii) = rda.VectorSize;
MRS_struct.p.LarmorFreq(ii) = rda.MRFrequency;
MRS_struct.p.npoints(ii) = rda.VectorSize;
%
% So now we should have got to the point after the header text
%
Expand Down

0 comments on commit 01d12ad

Please sign in to comment.