Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

NSxToHL.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. function NSxToHL(fname)
  2. % NSxToHL
  3. %
  4. % Opens and reads an NSx file without the header information and saves
  5. % the binary data into a .dat file with the same name. This can be used for
  6. % specific applications that require this type of data, e.g. Klusters.
  7. % Works with File Spec 2.1, 2.2 and 2.3.
  8. %
  9. % It does not support pauses at this time.
  10. %
  11. % Use OUTPUT = NSxToHL(fname)
  12. %
  13. % All input arguments are optional.
  14. %
  15. % fname: Name of the file to be opened. If the fname is omitted
  16. % the user will be prompted to select a file.
  17. % DEFAULT: Will open Open File UI.
  18. %
  19. % OUTPUT: Contains the binary data.
  20. %
  21. % Example 1:
  22. % NSxToHL('c:\data\sample.ns5');
  23. %
  24. % In the example above, the file c:\data\sample.ns5 will be opened and
  25. % the data will be read and saved without the header information in file
  26. % sample.ns5.dat.
  27. %
  28. % Example 2:
  29. % NSxToHL;
  30. %
  31. % In the example above, the file user will be prompted for the file. The
  32. % selected file (e.g. FILENAME.NSx) will be opened and the data will be
  33. % read and saved in the file FILENAME.NSx.dat.
  34. %
  35. % Kian Torab
  36. % kian@blackrockmicro.com
  37. % Blackrock Microsystems
  38. % Version 1.0.0.0
  39. %
  40. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  41. % Version History
  42. %
  43. % 1.0.0.0:
  44. % - Initial release.
  45. %
  46. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  47. %% Opening the file
  48. % Popup the Open File UI. Also, process the file name, path, and extension
  49. % for later use, and validate the entry.
  50. if ~exist('fname', 'var')
  51. if ~ismac
  52. [fname, path] = getFile('*.ns*', 'Choose an NSx file...');
  53. else
  54. [fname, path] = getFile('*.*', 'Choose an NSx file...');
  55. end
  56. if fname == 0
  57. disp('No file was selected.');
  58. if nargout
  59. clear variables;
  60. end
  61. return;
  62. end
  63. else
  64. if isempty(fileparts(fname))
  65. fname = which(fname);
  66. end
  67. [path,fname, fext] = fileparts(fname);
  68. fname = [fname fext];
  69. path = [path '/'];
  70. end
  71. if fname==0
  72. return;
  73. end
  74. %% Reading the headerless file
  75. data = openNSxHL([path fname]);
  76. %% Writing to file
  77. % Determining the filename for the converted file
  78. newFilename = [path fname '.dat'];
  79. % Opening the output file for saving
  80. FIDw = fopen(newFilename, 'w+', 'ieee-le');
  81. % Writing data into file
  82. disp('Writing the converted data into the new .dat file...');
  83. fwrite(FIDw, data, 'int16');