Connectivity.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. %% CorSE Algorithm for Functional Connectivity
  2. % This algorithm calculates the correlated spectral entropy (CorSE) based functional
  3. %connectivity between % two time series. For more information,
  4. %<http://journal.frontiersin.org/article/10.3389/fncom.2016.00112/full Kapucu et al.(2016)>. Please cite the paper if you have used or inspired by the method.
  5. %Copyright (c) 2016, Kapucu
  6. %All rights reserved.
  7. %Redistribution and use in source and binary forms, with or without
  8. %modification, are permitted provided that the following conditions are met:
  9. %* Redistributions of source code must retain the above copyright notice, this
  10. %list of conditions and the following disclaimer.
  11. %* Redistributions in binary form must reproduce the above copyright notice,
  12. %this list of conditions and the following disclaimer in the documentation
  13. %and/or other materials provided with the distribution
  14. %THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  15. %AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. %IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. %DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  18. %FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. %DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  20. %SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  21. %CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  22. %OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. %OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. %Select the .h5 file for yor analysis
  25. [file,path] = uigetfile('*.h5');
  26. TargetFile=[path file];
  27. Plate_type=h5readatt(TargetFile, '/DataInfo/', 'Plate type');
  28. if strcmp(Plate_type, '12-well plate')
  29. final_ch_col = 8;
  30. final_ch_row = 8;
  31. final_well_col = 4;
  32. final_well_row = 3;
  33. elseif strcmp(Plate_type, '48-well plate')
  34. final_ch_col = 4;
  35. final_ch_row = 4;
  36. final_well_col = 8;
  37. final_well_row = 6;
  38. else
  39. disp('Unknown MEA layout!')
  40. end
  41. ExcludedWells=h5read(TargetFile, '/DataInfo/ExcludedWells');
  42. disp('Note the excluded wells!:')
  43. disp(ExcludedWells)
  44. InactiveChannels=h5read(TargetFile, '/DataInfo/InactiveChannels');
  45. disp('Inactive channels!:')
  46. disp(InactiveChannels)
  47. %%
  48. prompt='Select your well.Please, use capital letters, e.g. A1:';
  49. MyWell = inputdlg(prompt);
  50. MyWell=MyWell{:};
  51. %%
  52. well_row=double(MyWell(1)-64);
  53. well_col=str2double(MyWell(2:end));
  54. %%
  55. splitter=@(x) strsplit(x, '/');
  56. RecordedWells={h5info(TargetFile).Groups(1).Groups.Name};
  57. if ~any(strcmp(cellfun(@(z) z{end}, cellfun(splitter,RecordedWells, 'UniformOutput',false), 'UniformOutput',false), MyWell))
  58. error(['Either well ' MyWell ' ' 'is excluded or it does not exist in the corresponding layout!']);
  59. end
  60. %%
  61. for i = 1 : final_ch_row
  62. for j = 1 : final_ch_col
  63. try
  64. temp = h5read(TargetFile, strcat('/Data/', MyWell, '/', num2str(i) , num2str(j)));
  65. catch
  66. disp(['The channel ' MyWell '_' num2str(i) num2str(j) ' is not recorded in the file'])
  67. temp=[];
  68. end
  69. DataCell{final_ch_row*(i-1)+j,7} = temp';
  70. DataCell{final_ch_row*(i-1)+j,1} = ['CH' num2str(i) num2str(j)];
  71. end
  72. end
  73. Spectral_entropy_HighPass_data_adaptive;