Skip to content
2 changes: 2 additions & 0 deletions +vlt/+data/hashmatlabvariable.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
% for information about the undocumented function getByteStreamFromArray
% function, upon which the default algorithm relies.
%
% Requires: DataHash (third-party, available on MATLAB File Exchange)
%
% See also: DataHash
%
% Example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function convertvhlvdatafile2integer(myfilename, headerstruct, outputfilename, s
multiplexed = headerstruct.Multiplexed;
end;

fid = fopen(myfilename,'r');
fid = fopen(myfilename,'rb');
if fid<0, error(['Could not open file ' myfilename '.']); end;

total_samples_per_chunk = headerstruct.SamplesPerChunk * headerstruct.NumChans; %
Expand Down
2 changes: 1 addition & 1 deletion +vlt/+file/+custom_file_formats/readroirawdatafile.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
waveforms = [];

if ischar(file_or_fid),
fid = fopen(file_or_fid,'r','b'); % big endian
fid = fopen(file_or_fid,'rb','b'); % big endian
if fid<0,
error(['Could not open file ' file_or_fid '.']);
end;
Expand Down
2 changes: 1 addition & 1 deletion +vlt/+file/+custom_file_formats/readvhlspikewaveformfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
waveforms = [];

if ischar(file_or_fid),
fid = fopen(file_or_fid,'r','b'); % big endian
fid = fopen(file_or_fid,'rb','b'); % big endian
if fid<0,
error(['Could not open file ' file_or_fid '.']);
end;
Expand Down
2 changes: 1 addition & 1 deletion +vlt/+file/+custom_file_formats/readvhlvdatafile.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

% open the file, skip through to the chunk where we will start reading

fid = fopen(myfilename,'r');
fid = fopen(myfilename,'rb');

if fid<0, error(['Could not open file ' myfilename '.']); end;

Expand Down
2 changes: 1 addition & 1 deletion +vlt/+file/+custom_file_formats/readvhlvdatafile_orig.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

% open the file, skip through to the chunk where we will start reading

fid = fopen(myfilename,'r');
fid = fopen(myfilename,'rb');

if fid<0, error(['Could not open file ' myfilename '.']); end;

Expand Down
2 changes: 1 addition & 1 deletion +vlt/+file/+custom_file_formats/vhsb_read.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

% vlt.file.custom_file_formats.vhsb_readheader will close the file

fo = fopen(fo,'r','ieee-le');
fo = fopen(fo,'rb','ieee-le');

% calculate sample number

Expand Down
2 changes: 1 addition & 1 deletion +vlt/+file/+custom_file_formats/vhsb_readheader.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
error(['Could not find file ' vlt.file.filename_value(fo) '.']);
end;

fo = fopen(fo,'r','ieee-le');
fo = fopen(fo,'rb','ieee-le');

headersize = 1836;

Expand Down
8 changes: 4 additions & 4 deletions +vlt/+file/arefilessame.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
file2 char {mustBeFile}
end; % arguments

fid1 = fopen(file1,'r');
fid2 = fopen(file2,'r');
fid1 = fopen(file1,'rb');
fid2 = fopen(file2,'rb');

if fid1<0,
error(['Could not open ' file1 ' for reading.']);
Expand All @@ -27,8 +27,8 @@
b = 1;

while ~feof(fid1),
D1 = fread(fid1,buffersize,'char');
D2 = fread(fid2,buffersize,'char');
D1 = fread(fid1,buffersize,'uint8');
D2 = fread(fid2,buffersize,'uint8');
b = isequaln(D1,D2);
if ~b,
fclose(fid1);
Expand Down
2 changes: 1 addition & 1 deletion +vlt/+file/loadIgor.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
elseif nargin==3, start=fix(start0)-1; stop=fix(stop0);
elseif nargin==2, error('LoadIgor needs 1 or 3 arguments.'); end;

fid = fopen(filename, 'r','b');
fid = fopen(filename, 'rb','b');

if (fid>2), % successful file open
s = fseek(fid,17,'bof');
Expand Down
2 changes: 1 addition & 1 deletion +vlt/+file/readlabviewarray.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

if nargin<3, mf = 'b'; else, mf = machineformat; end;

fid = fopen(fname, 'r',mf);
fid = fopen(fname, 'rb',mf);

if fid>0,
dims = fread(fid,2,'int');
Expand Down
8 changes: 8 additions & 0 deletions +vlt/+unittest/+data/test_hashmatlabvariable.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
properties
end

methods (TestClassSetup)
function checkDataHashAvailable(testCase)
if ~exist('DataHash','file')
testCase.assumeFail('DataHash is not installed. Skipping tests.');
end
end
end

methods (Test)
function test_hash_consistency(testCase)
% Test that hashing is consistent for the same data
Expand Down
8 changes: 8 additions & 0 deletions +vlt/+unittest/+deprecated/+data/test_hashmatlabvariable.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
properties
end

methods (TestClassSetup)
function checkDataHashAvailable(testCase)
if ~exist('DataHash','file')
testCase.assumeFail('DataHash is not installed. Skipping tests.');
end
end
end

methods (Test)
function test_hash_consistency(testCase)
% Test that hashing is consistent for the same data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,14 @@ function teardown(testCase)
function test_savefigurelist_saves_files(testCase)
% Test that savefigurelist saves files in the specified formats

% Get the current working directory to restore it later
originalDir = pwd;
% Change to the temporary directory
cd(testCase.tempDir);

% Define the formats to save
formatsToSave = {'fig', 'pdf'};

% Run the function
% Run the function from the temporary directory
cd(testCase.tempDir);
testCase.addTeardown(@() cd(tempdir));
savefigurelist(testCase.fig, 'Formats', formatsToSave);

% Change back to the original directory
cd(originalDir);

% Verify that the files were created in the temporary directory
for i = 1:length(formatsToSave)
expectedFile = fullfile(testCase.tempDir, ['myTestFigure.' formatsToSave{i}]);
Expand Down
3 changes: 2 additions & 1 deletion +vlt/+unittest/+file/drivepathTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
methods(Test)
function test_drivepath_output(testCase)
% Test the output of drivepath based on the current OS
% Note: On Linux (GLNXA64) drivepath returns '/media'.

p = vlt.file.drivepath();

switch computer
case 'GLNXA66'
case 'GLNXA64'
expected = '/media';
case 'MACI64'
expected = '/Volumes';
Expand Down
12 changes: 3 additions & 9 deletions +vlt/+unittest/+matlab/+graphics/test_savefigurelist.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,14 @@ function teardown(testCase)
function test_savefigurelist_saves_files(testCase)
% Test that savefigurelist saves files in the specified formats

% Get the current working directory to restore it later
originalDir = pwd;
% Change to the temporary directory
cd(testCase.tempDir);

% Define the formats to save
formatsToSave = {'fig', 'pdf'};

% Run the function
% Run the function from the temporary directory
cd(testCase.tempDir);
testCase.addTeardown(@() cd(tempdir));
vlt.matlab.graphics.savefigurelist(testCase.fig, 'Formats', formatsToSave);

% Change back to the original directory
cd(originalDir);

% Verify that the files were created in the temporary directory
for i = 1:length(formatsToSave)
expectedFile = fullfile(testCase.tempDir, ['myTestFigure.' formatsToSave{i}]);
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Run MATLAB Tests

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
with:
products: >
Statistics_and_Machine_Learning_Toolbox
Curve_Fitting_Toolbox
Optimization_Toolbox
Signal_Processing_Toolbox
Image_Processing_Toolbox
Deep_Learning_Toolbox

- name: Run tests
uses: matlab-actions/run-command@v2
with:
command: |
userpath(tempdir);
vlt_Init;
suite = matlab.unittest.TestSuite.fromPackage('vlt.unittest', 'IncludingSubpackages', true);
runner = matlab.unittest.TestRunner.withTextOutput;
results = runner.run(suite);
disp(table(results));
assert(all(~[results.Failed]), 'Some tests failed.');
2 changes: 1 addition & 1 deletion file/custom_file_formats/convertvhlvdatafile2integer.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function convertvhlvdatafile2integer(myfilename, headerstruct, outputfilename, s
multiplexed = headerstruct.Multiplexed;
end;

fid = fopen(myfilename,'r');
fid = fopen(myfilename,'rb');
if fid<0, error(['Could not open file ' myfilename '.']); end;

total_samples_per_chunk = headerstruct.SamplesPerChunk * headerstruct.NumChans; %
Expand Down
2 changes: 1 addition & 1 deletion file/custom_file_formats/readroirawdatafile.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
waveforms = [];

if ischar(file_or_fid),
fid = fopen(file_or_fid,'r','b'); % big endian
fid = fopen(file_or_fid,'rb','b'); % big endian
if fid<0,
error(['Could not open file ' file_or_fid '.']);
end;
Expand Down
2 changes: 1 addition & 1 deletion file/custom_file_formats/readvhlspikewaveformfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
waveforms = [];

if ischar(file_or_fid),
fid = fopen(file_or_fid,'r','b'); % big endian
fid = fopen(file_or_fid,'rb','b'); % big endian
if fid<0,
error(['Could not open file ' file_or_fid '.']);
end;
Expand Down
2 changes: 1 addition & 1 deletion file/custom_file_formats/readvhlvdatafile.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

% open the file, skip through to the chunk where we will start reading

fid = fopen(myfilename,'r');
fid = fopen(myfilename,'rb');

if fid<0, error(['Could not open file ' myfilename '.']); end;

Expand Down
2 changes: 1 addition & 1 deletion file/custom_file_formats/readvhlvdatafile_orig.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

% open the file, skip through to the chunk where we will start reading

fid = fopen(myfilename,'r');
fid = fopen(myfilename,'rb');

if fid<0, error(['Could not open file ' myfilename '.']); end;

Expand Down
2 changes: 1 addition & 1 deletion file/custom_file_formats/vhsb_read.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

% vhsb_readheader will close the file

fo = fopen(fo,'r','ieee-le');
fo = fopen(fo,'rb','ieee-le');

% calculate sample number

Expand Down
2 changes: 1 addition & 1 deletion file/custom_file_formats/vhsb_readheader.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
error(['Could not find file ' filename_value(fo) '.']);
end;

fo = fopen(fo,'r','ieee-le');
fo = fopen(fo,'rb','ieee-le');

headersize = 1836;

Expand Down
2 changes: 1 addition & 1 deletion file/loadIgor.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
elseif nargin==3, start=fix(start0)-1; stop=fix(stop0);
elseif nargin==2, error('LoadIgor needs 1 or 3 arguments.'); end;

fid = fopen(filename, 'r','b');
fid = fopen(filename, 'rb','b');

if (fid>2), % successful file open
s = fseek(fid,17,'bof');
Expand Down
2 changes: 1 addition & 1 deletion file/readlabviewarray.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

if nargin<3, mf = 'b'; else, mf = machineformat; end;

fid = fopen(fname, 'r',mf);
fid = fopen(fname, 'rb',mf);

if fid>0,
dims = fread(fid,2,'int');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@

[pathname filename2 extension] = fileparts(filename);
if strcmpi(extension,'.smr'), % little endian
fid=fopen(filename,'r','l');
fid=fopen(filename,'rb','l');
elseif strcmp(extension,'.son'), % big endian
fid=fopen(filename,'r','b');
fid=fopen(filename,'rb','b');
else,
error(['Unknown extension for SOM/SMR file: .' extension '.']);
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

[pathname filename2 extension] = fileparts(filename);
if strcmpi(extension,'.smr'), % little endian
fid=fopen(filename,'r','l');
fid=fopen(filename,'rb','l');
elseif strcmp(extension,'.son'), % big endian
fid=fopen(filename,'r','b');
fid=fopen(filename,'rb','b');
else,
error(['Unknown extension for SOM/SMR file: .' extension '.']);
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@

[pathname filename2 extension] = fileparts(filename);
if strcmpi(extension,'.smr'), % little endian
fid=fopen(filename,'r','l');
fid=fopen(filename,'rb','l');
elseif strcmp(extension,'.son'), % big endian
fid=fopen(filename,'r','b');
fid=fopen(filename,'rb','b');
else,
error(['Unknown extension for SOM/SMR file: .' extension '.']);
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
end;

for i=1:length(varargin),
fid_i = fopen(varargin{i},'r'); % should not fail because we've already read header files
fid_i = fopen(varargin{i},'rb'); % should not fail because we've already read header files
if i~=1, % if i==1, copy the header, too
fseek(fid_i,h{i}.fileinfo.headersize,'bof');
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
status = 0;
h = read_Intan_RHD2000_header(filename_in);

fid_i = fopen(filename_in,'r');
fid_i = fopen(filename_in,'rb');
fid_o = fopen(filename_out,'w');
if fid_o<0,
error(['Could not open the file ' filename_out ' for writing.']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

fn = fixdatfilename([directory_name filesep filename_post]);

fid = fopen(fn,'r','ieee-le');
fid = fopen(fn,'rb','ieee-le');
if fid<0
error(['Could not open ' fn ' for reading.']);
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@

% NOW, WE KNOW WHAT TO READ, LET'S READ IT

fid = fopen(filename,'r');
fid = fopen(filename,'rb');
if fileid_value(fid)<0,
error(['Could not open filename ' filename_value(filename) ' for reading (check path, spelling, permissions).']);
end;
Expand Down
Loading
Loading