Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions aod/AodHRVolumeReader.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@

classdef AodHRVolumeReader < HDF5Helper
properties
x = [];
y = [];
z = [];
reps = [];
version = [];
vfilename = [];
end

methods
function self = AodHRVolumeReader(filename,vfilename)

self = self@HDF5Helper(filename, 'ImData');

isHRV = (H5Tools.existAttribute(self.fp,'CellFocussedVolume') && ...
H5Tools.readAttribute(self.fp, 'CellFocussedVolume') == 1);
self.version = H5Tools.readAttribute(self.fp, 'Version');
assert((H5Tools.existAttribute(self.fp,'ScanType') && ...
strncmp(H5Tools.readAttribute(self.fp, 'ScanType')', 'Volume', 6) == 1) ...
|| isHRV , ...
'Not a volume scan file');


coord = AodCoordinatesReader(self.filename,self.version);
coords = coord(:);
numPoints = size(coords,1);
self.reps = floor(self.sz(1) / numPoints);

ar = aodReader(vfilename,'Volume');

self.x = ar.x;
self.y = ar.y;
self.z = ar.z;
self.vfilename = vfilename;

end

function volume = subsref(self, s)

ar = aodReader(self.filename,'Functional');
data = ar(:,:,:);
coord = AodCoordinatesReader(self.filename,self.version);
coords = coord(:);
volume = nan(length(self.x),length(self.y),length(self.z),size(data,1),size(data,3));

for i = 1:size(coords,1)
xind = find(single(coords(i,1))==single(self.x));
yind = find(single(coords(i,2))==single(self.y));
zind = find(single(coords(i,3))==single(self.z));
volume(xind,yind,zind,:,:) = squeeze(data(:,i,:));
end

if(strcmp(s(1).type,'()') == 0)
if 0 && ismember(s.subs,properties(self))
volume = self.(s.subs);
return;
end
volume = subsref@HDF5Helper(self,s);
return
end

% make sure subscripting has the right form
assert(numel(s) == 1 && strcmp(s.type, '()') && numel(s.subs) == 5 || ...
numel(s) == 1 && strcmp(s.type, '()') && numel(s.subs) == 4 || ...
numel(s) == 1 && strcmp(s.type, '()') && numel(s.subs) == 3, ...
'MATLAB:badsubscript', 'Only subscripting of the form (samples, channels) is allowed!')

% samples and channels
x = s(1).subs{1};
y = s(1).subs{2};
z = s(1).subs{3};

if numel(s(1).subs)<5
chan = 1;
else
chan = s(1).subs{5};
end

if numel(s(1).subs) < 4
reps = 1:self.reps;
else
reps = s(1).subs{4};
end

% all samples requested?
if ~HDF5Helper.iscolon(x)
volume = volume(x,:,:,:,:);
end

% all samples requested?
if ~HDF5Helper.iscolon(y)
volume = volume(:,y,:,:,:);
end

% all samples requested?
if ~HDF5Helper.iscolon(z)
volume = volume(:,:,z,:,:);
end

% all samples requested?
if ~HDF5Helper.iscolon(reps)
volume = volume(:,:,:,reps,:);
end

% all channels requested?
if ~HDF5Helper.iscolon(chan)
volume = volume(:,:,:,:,chan);
end

end
end
end
133 changes: 0 additions & 133 deletions aod/AodScanReader.asv

This file was deleted.

2 changes: 2 additions & 0 deletions aod/aodReader.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
br = AodMotionReader(fileName);
elseif strcmp(dataset, 'Volume') == 1
br = AodVolumeReader(fileName);
elseif strcmp(dataset, 'HRVolume') ==1
br = AodHRVolumeReader(fileName,varargin{1});
else
error('Unknown dataset. Options are Temporal, Functional,Volume and Motion.');
end
Loading