Skip to content

Commit

Permalink
Fixed a bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kian Torab committed Sep 3, 2017
1 parent 03c2b1c commit 50069bb
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions NPMK/openNSx.m
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@
% - Fixed a serious bug related to loading paused files.
% - Fixed a bug where an empty data segment resulted in a cell structure.
%
% 6.4.1.0: June 15, 2017
% - It is no longer necessary to provide the full path for loading a
% file.
%
% 6.4.2.0: September 1, 2017
% - Fixed a bug related to reading data from sample that is not 1 and
% timestamp that used to get reset to 0.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Defining the NSx data structure and sub-branches.
Expand Down Expand Up @@ -340,7 +348,8 @@
(strcmpi(temp(3),'\') || ...
strcmpi(temp(1),'/') || ...
strcmpi(temp(2),'/') || ...
strcmpi(temp(1:2), '\\'))
strcmpi(temp(1:2), '\\') || ...
strcmpi(temp(end-3), '.'))
fname = inputArgument;
if exist(fname, 'file') ~= 2
disp('The file does not exist.');
Expand Down Expand Up @@ -503,7 +512,9 @@
% Read Raw Header for saveNSx
fseek(FID, 0, 'bof');
NSx.RawData.Headers = fread(FID, f.EOexH, '*uint8');
% if strcmpi(NSx.MetaTags.FileTypeID, 'NEURALCD')
NSx.RawData.DataHeader = fread(FID, 9, '*uint8');
% end
fseek(FID, f.EOexH, 'bof');


Expand Down Expand Up @@ -662,6 +673,8 @@
NSx.MetaTags.ChannelCount = length(userRequestedChannels);
end
end
else
NSx.MetaTags.ChannelCount = length(userRequestedChannels);
end

for idx = 1:length(userRequestedChannels)
Expand Down Expand Up @@ -718,7 +731,7 @@
StartPacket = 1;
end
if EndPacket > sum(NSx.MetaTags.DataPoints)
if StartPacket >= sum(NSx.MetaTags.DataPoints)
if StartPacket >= NSx.MetaTags.DataPoints
disp('The starting packet is greater than the total data duration.');
disp('The file was not read.');
fclose(FID);
Expand Down Expand Up @@ -857,7 +870,7 @@
NSx.MetaTags.ChannelID(channelIDToDelete) = [];

%% Adjusting the file for a non-0 timestamp start
if ~NSx.RawData.PausedFile
if ~NSx.RawData.PausedFile & StartPacket == 1
if length(NSx.MetaTags.Timestamp) > 1
cellIDX = 1; % only do this for the first cell segment and not modify the subsequent segments
if strcmpi(ReadData, 'read')
Expand Down Expand Up @@ -915,7 +928,7 @@
%% If user does not specify an output argument it will automatically create
% a structure.
outputName = ['NS' fext(4)];
if (nargout == 0),
if (nargout == 0)
assignin('caller', outputName, NSx);
else
varargout{1} = NSx;
Expand All @@ -926,4 +939,4 @@
end
fclose(FID);

end
end

0 comments on commit 50069bb

Please sign in to comment.