splitNEVNTrode.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  39. % Validating input parameter
  40. ccf = openCCF;
  41. splitCount = length(ccf.NTrodeInfo.NTrodeID);
  42. % Getting the file name
  43. if ~ismac
  44. [fname, path] = getFile('*.nev', 'Choose an NEV file...');
  45. else
  46. [fname, path] = getFile('*.nev', 'Choose an NEV file...');
  47. end
  48. if fname == 0
  49. disp('No file was selected.');
  50. if nargout
  51. clear variables;
  52. end
  53. return;
  54. end
  55. fext = fname(end-3:end);
  56. % Loading the file
  57. for idx = 1:splitCount
  58. % Determining whether tetrode channel is recorded and valid in NSx
  59. tetrodeChannels = ccf.NTrodeInfo.NTrodeMembers{idx};
  60. NEV = openNEV([path, fname(1:end-4) '.nev'], ['c:' num2str(tetrodeChannels)]); % modified by SH 05-Oct-2016
  61. newFileName = [path fname(1:end-4) '-tet' sprintf('%03d', idx) fname(end-3:end)];
  62. saveNEV(NEV, newFileName, 'noreport');
  63. end