splitNEVNTrode.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. function splitNSxNTrode
  2. % splitNEVNTrode
  3. %
  4. % Opens and splits an NEV file based on its NTrode groups. It depends on
  5. % openCCF file.
  6. %
  7. % Use splitNEVNTrode
  8. %
  9. % This function does not take any inputs.
  10. %
  11. % Example 1:
  12. % splitNEVNTrode;
  13. %
  14. % In the example above, the user will be prompted to select a CCF file
  15. % first. The CCF contains the ntrode grouping infromation. Then the user
  16. % will be prompted to select a NEV file. The script will then split the
  17. % NEV file into smaller NEV files containing channels in given ntrode
  18. % groups. For example, if ntrode group one consists of channels 1,3,5,
  19. % and 12, then using splitNEVNTrode will split the file into a smaller
  20. % NEV files that contains those channels only. If there are multiple
  21. % ntrodes then the files will split into multiple smaller files, equal in
  22. % number of the ntrode groups.
  23. %
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25. % Kian Torab
  26. % support@blackrockmicro.com
  27. % Blackrock Microsystems
  28. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29. % Version History
  30. %
  31. % 1.0.0.0: January 18, 2016
  32. % - Initial release.
  33. %
  34. % 1.1.0.0: October 10, 2016 - Saman Hagh Gooie
  35. % - Bug fixes with file loading
  36. % - Fixed the file extension used for saving
  37. %
  38. % 1.2.0.0: October 27, 2020
  39. % - Removed junk characters from the file.
  40. %
  41. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  42. % Validating input parameter
  43. ccf = openCCF;
  44. splitCount = length(ccf.NTrodeInfo.NTrodeID);
  45. % Getting the file name
  46. [fname, path] = getFile('*.nev', 'Choose an NSx file...');
  47. if ~ismac
  48. [fname, path] = getFile('*.nev', 'Choose an NEV file...');
  49. else
  50. [fname, path] = getFile('*.nev', 'Choose an NEV file...');
  51. end
  52. if fname == 0
  53. disp('No file was selected.');
  54. if nargout
  55. clear variables;
  56. end
  57. return;
  58. end
  59. fext = fname(end-3:end);
  60. % Loading the file
  61. for idx = 1:splitCount
  62. % Determining whether tetrode channel is recorded and valid in NSx
  63. tetrodeChannels = ccf.NTrodeInfo.NTrodeMembers{idx};
  64. NEV = openNEV([path, fname(1:end-4) '.nev'], ['c:' num2str(tetrodeChannels)]); % modified by SH 05-Oct-2016
  65. newFileName = [path fname(1:end-4) '-tet' sprintf('%03d', idx) fname(end-3:end)];
  66. saveNEV(NEV, newFileName, 'noreport');
  67. end