openNSx
Opens and reads an NSx file then returns all file information in a NSx
structure. Works with File Spec 2.1, 2.2, 2.3, and 3.0.
Use OUTPUT = openNSx(fname, 'read', 'report', 'e:xx:xx', 'c:xx:xx', 't:xx:xx', 'mode', 'precision', 'skipfactor', 'nozeropad').
All input arguments are optional. Input arguments can be in any order.
fname: Name of the file to be opened. If the fname is omitted
the user will be prompted to select a file.
DEFAULT: Will open Open File UI.
'read': Will read the data in addition to the header information
if user passes this argument.
DEFAULT: will read the entire file.
'report': Will show a summary report if user passes this argument.
DEFAULT: will not show report.
'e:XX:YY': User can specify which electrodes need to be read. The
number of electrodes can be greater than or equal to 1
and less than or equal to 256. The electrodes can be
selected either by specifying a range (e.g. 20:45) or by
indicating individual electrodes (e.g. 3,6,7,90) or both.
Note that, when individual channels are to be read, all
channels in between will also be read. The prorgam will
then remove the unwanted channels. This may result in a
large memory footprint. If memory issues arrise please
consider placing openNSx in a for loop and reading
individual channels.
This field needs to be preceded by the prefix 'e:'. See
example for more details. If this option is selected the
user will be promped for a CMP mapfile (see: KTUEAMapFile)
provided by Blackrock Microsystems. This feature required
KTUEAMapFile to be present in path.
DEFAULT: will read all existing electrodes.
'c:XX:YY': User can specify which channels need to be read. The
number of channels can be greater than or equal to 1
and less than or equal to 272. The channels can be
selected either by specifying a range (e.g. 20:45) or by
indicating individual channels (e.g. 3,6,7,90) or both.
Note that, when individual channels are to be read, all
channels in between will also be read. The prorgam will
then remove the unwanted channels. This may result in a
large memory footprint. If memory issues arrise please
consider placing openNSx in a for loop and reading
individual channels.
This field needs to be preceded by the prefix 'c:'. See
example for more details.
DEFAULT: will read all existing analog channels.
't:XX:YY': User can specify the beginning and end of the data
segment to be read. If the start time is greater than the
length of data the program will exit with an errorNS
message. If the end time is greater than the length of
data the end packet will be selected for end of data. The
user can specify the start and end values by comma
(e.g. [20,50]) or by a colon (e.g. [20:50]). To use this
argument the user must specify the [electrodes] or the
interval will be used for [electrodes] automatically.
This field needs to be preceded by the prefix 't:'.
Note that if 'mode' is 'sample' the start duration cannot
be less than 1. The duration is inclusive.
See example for more details.
DEFAULT: will read the entire file.
'mode': The user can specify the mode of duration in [duration],
such as 'sec', 'min', 'hour', or 'sample'. If 'sec' is
specified the numbers in [duration] will correspond to
the number of seconds. The same is true for 'min', 'hour'
and 'sample'.
DEFAULT: reads 'sample'.
'uV': Will read the recording waveforms in unit of uV instead of
raw values. Note that this conversion may lead to loss of
information (e.g. 15/4 = 4) since the data type will
stay in int16. It's recommended to read raw spike
waveforms and then perform the conversion at a later
time.
DEFAULT: will read recording information in raw.
'precision': This will specify the precision for NSx file. If set to
'double' the NSx data will be read as 'double' and if set
to 'short', the NSx data will be read as 'int16' data
type. While reading the file as 'short' may have a much
smaller memory footprint and a faster read time, some
post data analysis such as multiplying the signal by a
factor that will make the data larger than (-32,768 to
32,767 -- refer to MATLAB documentation for more
information) may result in unexpected behavior.
Always use caution when using short. If you are not sure
of what to use then do not specify this option.
DEFAULT: will read data in 'int16'.
'skipfactor': This option will allow the user to read a decimated
version of the data. The skipfactor will determine how
many samples to skip. For example, if skipfactor is 2
then every other sample is read. If skipfactor is 5 then
every fifth sample is read. This is useful to briefly
looking at the data in a large datafile when reading the
entire dataset would overflow the memory.
DEFAULT: is set to 1, so every sample will be read.
'ver': If this argument is passed to the function it will return
the version number of the function without reading any
data files.
'nozeropad': It will not zeropad the data to compensate foro the non-
zero start time.
DEFAULT: zeropads the loaded data.
OUTPUT: Contains the NSx structure.
Example 1:
openNSx('report','read','c:\data\sample.ns5', 'e:15:30', 't:3:10','min', 'p:short', 's:5');
or equivalently
openNSx('report','read','c:\data\sample.ns5', 'electrodes', 15:30, 'duration', 3:10, 'min', 'precision', 'short', 'skipfactor', 5);
In the example above, the file c:\data\sample.ns5 will be used. A
report of the file contents will be shown. The data will be read from
electrodes 15 through 50 in the 3-10 minute time interval. A decimated
version of the datafile will be read, where only every 5th sample is read.
If any of the arguments above are omitted the default values will be used.
Example 2:
openNSx('read','c:15:30');
In the example above, the file user will be prompted for the file. The
file will be read using 'int16' precision as default. All time points
of Only channels 15 through 30 will be read. If any of the arguments
above are omitted the default values will be used.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Kian Torab
support@blackrockmicro.com
Blackrock Microsystems
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%