ReadAxionChannelnew.m 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. function [error,data,duration, chlabel] = ReadAxionChannel(obj)
  2. %well does not exist jump to another and display...might be not
  3. %recorded or so
  4. %jump to the next
  5. %if channel (single)does not exist then display channel not recorded
  6. %next
  7. data = []; %there in Meeri's code to return at least something with e.g. error=1
  8. %error = 0;
  9. %duration = [];
  10. m_well=strcat(char(64+obj.last_well_row+1),num2str(obj.last_well_col+1));
  11. fid = H5F.open(obj.getCurrentFile());
  12. gid = H5G.open(fid,['/Data/' m_well]);
  13. while ~H5L.exists(gid,'slink','H5P_DEFAULT')
  14. fprintf([mwell 'seems to be excluded\n']);
  15. obj = obj.JumpNextWell;
  16. m_well=strcat(char(64+obj.last_well_row+1),num2str(obj.last_well_col+1));
  17. gid = H5G.open(fid,['/Data/' m_well]);
  18. end
  19. %m_well=strcat(char(64+obj.last_well_row+1),num2str(obj.last_well_col+1));
  20. m_ch=strcat(num2str(obj.last_ch_col+1),num2str(obj.last_ch_row+1));
  21. chlabel = strcat(m_well,'_',m_ch); % which well which electrode
  22. disp(['now reading: ' chlabel]);
  23. try
  24. data = h5read(obj.getCurrentFile(),['/Data/' m_well '/' m_ch]);
  25. %if isempty(obj.duration)
  26. %duration = length(data)/obj.samplerate;
  27. %obj.duration = duration;
  28. %else
  29. %duration = obj.duration;%better when open file?????
  30. %end
  31. error = 0;
  32. catch %err
  33. error = 1;
  34. InactiveChannels=h5read(obj.getCurrentFile(), '/DataInfo/InactiveChannels');
  35. if any(contains(InactiveChannels, chlabel))
  36. disp(['Channel' ' ' chlabel ' ' 'is inactive, it is not recorded in the initial analysed file.'])
  37. else
  38. disp(['Smth wrong with' ' ' chlabel ' ' 'channel reading!']); %ADDED
  39. end
  40. end
  41. end
  42. %%
  43. function obj = JumpNextWell(obj)
  44. if obj.final_well_col-1 <= obj.last_well_col
  45. obj.last_well_col = obj.first_well_col-1;
  46. if obj.final_well_row-1 <= obj.last_well_row
  47. disp('All channels have been read from!');
  48. obj.file_finished = 1;
  49. else
  50. obj.last_well_row = obj.last_well_row+1;
  51. end
  52. else
  53. obj.last_well_col = obj.last_well_col+1;
  54. end
  55. end