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.

mergeNEV.m 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. function [NEV] = mergeNEV()
  2. %%
  3. % Saves a new NEV file that contains event data from one NEV and spike data
  4. % from another
  5. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6. % Use: mergeNEV()
  7. %mergeNEV version = '1.0.0.0';
  8. %Author: Nick Halper
  9. %Contact: nhalper@blackrockmicro.com
  10. %%
  11. % Choose file that contains event data
  12. uiwait(msgbox('Choose the file containing event data (comments, digital inputs, etc) that you want to keep','Choose Event Data','modal'));
  13. EventNEV = openNEV();
  14. uiwait(msgbox('Choose the file containing sorted spike data that you want to keep','Choose Spike Data','modal'));
  15. SpikeNEV = openNEV();
  16. for i = 1:length(SpikeNEV.MetaTags.ChannelID)
  17. EventIndices = find(EventNEV.Data.Spikes.Electrode == SpikeNEV.MetaTags.ChannelID(i));
  18. SpikeDataIndices = find(SpikeNEV.Data.Spikes.Electrode == SpikeNEV.MetaTags.ChannelID(i));
  19. EventNEV.Data.Spikes.TimeStamp(EventIndices) = [];
  20. EventNEV.Data.Spikes.Electrode(EventIndices) = [];
  21. EventNEV.Data.Spikes.Unit(EventIndices) = [];
  22. EventNEV.Data.Spikes.Waveform(:,EventIndices) = [];
  23. disp('Length of Spike Indices:');
  24. disp(length(SpikeDataIndices));
  25. disp('Length of Event Indices:');
  26. disp(length(EventIndices));
  27. EventNEV.Data.Spikes.TimeStamp = [EventNEV.Data.Spikes.TimeStamp SpikeNEV.Data.Spikes.TimeStamp(SpikeDataIndices)];
  28. EventNEV.Data.Spikes.Electrode = [EventNEV.Data.Spikes.Electrode SpikeNEV.Data.Spikes.Electrode(SpikeDataIndices)];
  29. EventNEV.Data.Spikes.Unit = [EventNEV.Data.Spikes.Unit SpikeNEV.Data.Spikes.Unit(SpikeDataIndices)];
  30. EventNEV.Data.Spikes.Waveform = [EventNEV.Data.Spikes.Waveform SpikeNEV.Data.Spikes.Waveform(:,SpikeDataIndices)];
  31. [EventNEV.Data.Spikes.TimeStamp, ISort] = sort(EventNEV.Data.Spikes.TimeStamp);
  32. EventNEV.Data.Spikes.Electrode = EventNEV.Data.Spikes.Electrode(ISort);
  33. EventNEV.Data.Spikes.Unit = EventNEV.Data.Spikes.Unit(ISort);
  34. EventNEV.Data.Spikes.Waveform = EventNEV.Data.Spikes.Waveform(:,ISort);
  35. end
  36. SpikeNEV.MetaTags.ChannelID = EventNEV.MetaTags.ChannelID;
  37. SpikeNEV.MetaTags.HeaderOffset = EventNEV.MetaTags.HeaderOffset;
  38. EventNEV.MetaTags = SpikeNEV.MetaTags;
  39. %EventNEV.Data.Spikes = SpikeNEV.Data.Spikes;
  40. NEV = EventNEV;
  41. uiwait(msgbox('Choose the save location for the new file','Choose Save Location','modal'));
  42. [FileName,PathName] = uiputfile('.nev');
  43. SavePath = fullfile(PathName,FileName);
  44. saveNEV(NEV,fullfile(PathName,FileName));
  45. end