Skip to content

Commit

Permalink
Merge commit '90f0d93' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoostenveld committed Jun 3, 2024
2 parents 12640c5 + 90f0d93 commit f1edbb0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 21 additions & 0 deletions fileio/ft_filetype.m
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,10 @@
type = 'polhemus_pos';
manufacturer = 'BrainProducts/CTF/Polhemus?'; % actually I don't know whose software it is
content = 'electrode positions';
elseif filetype_check_extension(filename, '.txt') && filetype_header_contains(filename, 'FastSCAN', 300)
type = 'fastscan_txt';
manufacturer = 'Polhemus FastSCAN';
content = 'headshape points';

% known Blackrock Microsystems file types
elseif strncmp(x,'.ns',3) && (filetype_check_header(filename, 'NEURALCD') || filetype_check_header(filename, 'NEURALSG'))
Expand Down Expand Up @@ -1799,6 +1803,23 @@
res=any(ft_filetype(neuralynxdirs, 'neuralynx_ds'));
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SUBFUNCTION that checks whether the file contains only ascii characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function res = filetype_header_contains(filename, pat, len)
if exist(filename, 'file')
fid = fopen(filename, 'rt');
try
str = fread(fid, [1 len], 'uint8=>char');
catch
str = fread(fid, [1 inf], 'uint8=>char');
end
fclose(fid);
res = contains(str, pat);
else
res = false;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SUBFUNCTION that checks whether the file contains only ascii characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
6 changes: 4 additions & 2 deletions fileio/private/read_trigger.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@
for i = 1:size(dat,1)
threshold_value = eval([threshold '(dat(i,:))']);
% discretize the signal
dat(i,dat(i,:)< threshold_value) = 0;
dat(i,dat(i,:)>=threshold_value) = 1;
below = dat(i,:)< threshold_value;
above = dat(i,:)>=threshold_value;
dat(i,below) = 0;
dat(i,above) = 1;
end
else
% discretize the signal
Expand Down

0 comments on commit f1edbb0

Please sign in to comment.