Getting error 'fl:filesy​stem:Syste​mError' when trying to read a file

3 次查看(过去 30 天)
Hi, I'm trying to read in data and separate it into discrete files using matlab running on linux. I've done this before when I've written code for every data set, but I was hoping I could get it so that I could write one piece of code that would iterate through all my files. However, it fails with the above error at the fifth line (data = h5read...) and i'm not sure why. I'm attaching my code and a picture of my file structure since I think the issue is coming from there, I just don't know why. I appreciate any help anyone might offer.
clear, clc
for j = 4:16
batch_path = strcat('2018-07-05-video-', num2str(j, '%02d'), '/2018-07-05-video-', num2str(j, '%02d'), '-hdf5/');
batch_filename = strcat('2018-07-05-video-', num2str(j, '%02d'), '/2018-07-05-video-', num2str(j, '%02d'), '-hdf5/2018-07-05-video-', num2str(j, '%02d'), '-batch.h5');
disp('test1');
data = h5read(batch_filename, '/data');
disp('test2');
mask = ones(1920,1080);
mask(780:1150, 70:1080) = 1;
mask = uint8(mask);
one = uint8(1);
% scale in pixels/millimeter as determined by fiji
scale = 1808/144.6;
bounds_all = [0; 1920/scale; 0; 1080/scale];
deltaTime = .00104;
for i = 1:1:size(data,3)
filename = strcat(batch_path, '2018-07-05-video-', num2str(j, '%02d'), '-frame-', num2str(i,'%03d'), '.h5');
% The next block creates and empty hdf5 file and initialized empty datasets
% required by ACCIV. Four datasets are required: /data, /mask, /bounds, and
% /time. /data is a 2-dimensional array with columns and rows equal to the
% resolution of the image to be imported. The data for /data is required to
% be a double datatype for ACCIV to read it. /mask is the same as /data,
% except it needs to be entered as a uint8 and possibly with a chunksize
% equal to the dimensions (unknown what was causing the error, I just made
% every aspect match the Galileo source file). The /mask matrix has two
% values, 0 where the data should be ignored and 1 where the data needs to
% be analyzed. It's currently set to read everything, I need to explore how
% to set the mask correctly. Finally, /time is the timestamp of the frame.
% I set the first image to a time of 0 and increment it by 104.167
% microseconds. So the ith image would have a time of 104.167*i
% microseconds. The time datatype must be a uint8 to work.
h5create(filename, '/data', [1920 1080]);
h5create(filename, '/mask', [1920 1080], 'Datatype', 'uint8', 'ChunkSize', [1920 1080], 'FillValue', one);
h5create(filename, '/bounds', 4);
h5create(filename, '/time', 1);
h5disp(filename);
% The last block writes data into the empty datasets created in the
% previous block. /data is the data created in imagej casted to a double
% type, mask and bounds are extracted from datasets i created in hdfview,
% and time is a uint8 that represents the total time since the first image
% (i.e. for us it will be 0, 104.167, 208.333, ..., 104.167*i, ...)
% recorded in microseconds.
h5write(filename, '/data', double(data(:,:,i)));
h5write(filename, '/mask', mask);
h5write(filename, '/bounds', bounds_all);
h5write(filename, '/time', (i-1)*deltaTime);
end
end

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by