-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41792a4
commit 3472e63
Showing
6 changed files
with
268 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function test_suite=test_fiff_finish_writing_raw | ||
try test_functions=localfunctions(); catch | ||
end | ||
initTestSuite; | ||
|
||
function test_fiff_readwrite_raw_() | ||
% Test a round trip of reading and writing raw data | ||
% this function calls the following relevant m-files: | ||
% - fiff_read_meas_info | ||
% - fiff_setup_read_raw | ||
% - fiff_read_raw_segment | ||
% - fiff_start_writing_raw | ||
% - fiff_write_int | ||
% - fiff_write_raw_buffer | ||
% - fiff_finish_writing_raw | ||
|
||
FIFF = fiff_define_constants; | ||
|
||
% read | ||
pathstr = fileparts(mfilename('fullpath')); | ||
fname = fullfile(pathstr, 'data', 'test_raw.fif'); | ||
info = fiff_read_meas_info(fname); | ||
raw = fiff_setup_read_raw(fname); | ||
[data, times] = fiff_read_raw_segment(raw); | ||
|
||
% write -> note that the original data was in 24 chunks of 600 samples, the | ||
% data is saved out as a single chunk of 14400 samples | ||
fnamenew = strrep(fname, 'test_', 'testout_'); | ||
[outfid, cals] = fiff_start_writing_raw(fnamenew, info); | ||
fiff_write_int(outfid, FIFF.FIFF_FIRST_SAMPLE, raw.first_samp); | ||
fiff_write_int(outfid, FIFF.FIFF_DATA_SKIP, 0); | ||
fiff_write_raw_buffer(outfid, data, cals); | ||
fiff_finish_writing_raw(outfid); | ||
|
||
% read the new file | ||
rawnew = fiff_setup_read_raw(fnamenew); | ||
[datanew, timesnew] = fiff_read_raw_segment(rawnew); | ||
|
||
% compare | ||
assertEqual(data, datanew); | ||
assertEqual(times, timesnew); | ||
|
||
% clean up | ||
delete(fnamenew); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function test_suite=test_fiff_read_meas_info | ||
try test_functions=localfunctions(); catch | ||
end | ||
initTestSuite; | ||
|
||
function test_fiff_readwrite_raw_() | ||
% Test a round trip of reading and writing raw data | ||
% this function calls the following relevant m-files: | ||
% - fiff_read_meas_info | ||
% - fiff_setup_read_raw | ||
% - fiff_read_raw_segment | ||
% - fiff_start_writing_raw | ||
% - fiff_write_int | ||
% - fiff_write_raw_buffer | ||
% - fiff_finish_writing_raw | ||
|
||
FIFF = fiff_define_constants; | ||
|
||
% read | ||
pathstr = fileparts(mfilename('fullpath')); | ||
fname = fullfile(pathstr, 'data', 'test_raw.fif'); | ||
info = fiff_read_meas_info(fname); | ||
raw = fiff_setup_read_raw(fname); | ||
[data, times] = fiff_read_raw_segment(raw); | ||
|
||
% write -> note that the original data was in 24 chunks of 600 samples, the | ||
% data is saved out as a single chunk of 14400 samples | ||
fnamenew = strrep(fname, 'test_', 'testout_'); | ||
[outfid, cals] = fiff_start_writing_raw(fnamenew, info); | ||
fiff_write_int(outfid, FIFF.FIFF_FIRST_SAMPLE, raw.first_samp); | ||
fiff_write_int(outfid, FIFF.FIFF_DATA_SKIP, 0); | ||
fiff_write_raw_buffer(outfid, data, cals); | ||
fiff_finish_writing_raw(outfid); | ||
|
||
% read the new file | ||
rawnew = fiff_setup_read_raw(fnamenew); | ||
[datanew, timesnew] = fiff_read_raw_segment(rawnew); | ||
|
||
% compare | ||
assertEqual(data, datanew); | ||
assertEqual(times, timesnew); | ||
|
||
% clean up | ||
delete(fnamenew); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function test_suite=test_fiff_start_writing_raw | ||
try test_functions=localfunctions(); catch | ||
end | ||
initTestSuite; | ||
|
||
function test_fiff_readwrite_raw_() | ||
% Test a round trip of reading and writing raw data | ||
% this function calls the following relevant m-files: | ||
% - fiff_read_meas_info | ||
% - fiff_setup_read_raw | ||
% - fiff_read_raw_segment | ||
% - fiff_start_writing_raw | ||
% - fiff_write_int | ||
% - fiff_write_raw_buffer | ||
% - fiff_finish_writing_raw | ||
|
||
FIFF = fiff_define_constants; | ||
|
||
% read | ||
pathstr = fileparts(mfilename('fullpath')); | ||
fname = fullfile(pathstr, 'data', 'test_raw.fif'); | ||
info = fiff_read_meas_info(fname); | ||
raw = fiff_setup_read_raw(fname); | ||
[data, times] = fiff_read_raw_segment(raw); | ||
|
||
% write -> note that the original data was in 24 chunks of 600 samples, the | ||
% data is saved out as a single chunk of 14400 samples | ||
fnamenew = strrep(fname, 'test_', 'testout_'); | ||
[outfid, cals] = fiff_start_writing_raw(fnamenew, info); | ||
fiff_write_int(outfid, FIFF.FIFF_FIRST_SAMPLE, raw.first_samp); | ||
fiff_write_int(outfid, FIFF.FIFF_DATA_SKIP, 0); | ||
fiff_write_raw_buffer(outfid, data, cals); | ||
fiff_finish_writing_raw(outfid); | ||
|
||
% read the new file | ||
rawnew = fiff_setup_read_raw(fnamenew); | ||
[datanew, timesnew] = fiff_read_raw_segment(rawnew); | ||
|
||
% compare | ||
assertEqual(data, datanew); | ||
assertEqual(times, timesnew); | ||
|
||
% clean up | ||
delete(fnamenew); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function test_suite=test_fiff_write_int | ||
try test_functions=localfunctions(); catch | ||
end | ||
initTestSuite; | ||
|
||
function test_fiff_readwrite_raw_() | ||
% Test a round trip of reading and writing raw data | ||
% this function calls the following relevant m-files: | ||
% - fiff_read_meas_info | ||
% - fiff_setup_read_raw | ||
% - fiff_read_raw_segment | ||
% - fiff_start_writing_raw | ||
% - fiff_write_int | ||
% - fiff_write_raw_buffer | ||
% - fiff_finish_writing_raw | ||
|
||
FIFF = fiff_define_constants; | ||
|
||
% read | ||
pathstr = fileparts(mfilename('fullpath')); | ||
fname = fullfile(pathstr, 'data', 'test_raw.fif'); | ||
info = fiff_read_meas_info(fname); | ||
raw = fiff_setup_read_raw(fname); | ||
[data, times] = fiff_read_raw_segment(raw); | ||
|
||
% write -> note that the original data was in 24 chunks of 600 samples, the | ||
% data is saved out as a single chunk of 14400 samples | ||
fnamenew = strrep(fname, 'test_', 'testout_'); | ||
[outfid, cals] = fiff_start_writing_raw(fnamenew, info); | ||
fiff_write_int(outfid, FIFF.FIFF_FIRST_SAMPLE, raw.first_samp); | ||
fiff_write_int(outfid, FIFF.FIFF_DATA_SKIP, 0); | ||
fiff_write_raw_buffer(outfid, data, cals); | ||
fiff_finish_writing_raw(outfid); | ||
|
||
% read the new file | ||
rawnew = fiff_setup_read_raw(fnamenew); | ||
[datanew, timesnew] = fiff_read_raw_segment(rawnew); | ||
|
||
% compare | ||
assertEqual(data, datanew); | ||
assertEqual(times, timesnew); | ||
|
||
% clean up | ||
delete(fnamenew); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function test_suite=test_fiff_write_raw_buffer | ||
try test_functions=localfunctions(); catch | ||
end | ||
initTestSuite; | ||
|
||
function test_fiff_readwrite_raw_() | ||
% Test a round trip of reading and writing raw data | ||
% this function calls the following relevant m-files: | ||
% - fiff_read_meas_info | ||
% - fiff_setup_read_raw | ||
% - fiff_read_raw_segment | ||
% - fiff_start_writing_raw | ||
% - fiff_write_int | ||
% - fiff_write_raw_buffer | ||
% - fiff_finish_writing_raw | ||
|
||
FIFF = fiff_define_constants; | ||
|
||
% read | ||
pathstr = fileparts(mfilename('fullpath')); | ||
fname = fullfile(pathstr, 'data', 'test_raw.fif'); | ||
info = fiff_read_meas_info(fname); | ||
raw = fiff_setup_read_raw(fname); | ||
[data, times] = fiff_read_raw_segment(raw); | ||
|
||
% write -> note that the original data was in 24 chunks of 600 samples, the | ||
% data is saved out as a single chunk of 14400 samples | ||
fnamenew = strrep(fname, 'test_', 'testout_'); | ||
[outfid, cals] = fiff_start_writing_raw(fnamenew, info); | ||
fiff_write_int(outfid, FIFF.FIFF_FIRST_SAMPLE, raw.first_samp); | ||
fiff_write_int(outfid, FIFF.FIFF_DATA_SKIP, 0); | ||
fiff_write_raw_buffer(outfid, data, cals); | ||
fiff_finish_writing_raw(outfid); | ||
|
||
% read the new file | ||
rawnew = fiff_setup_read_raw(fnamenew); | ||
[datanew, timesnew] = fiff_read_raw_segment(rawnew); | ||
|
||
% compare | ||
assertEqual(data, datanew); | ||
assertEqual(times, timesnew); | ||
|
||
% clean up | ||
delete(fnamenew); | ||
|