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.

Figure_2.m 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. function fig = Figure_2( strNIXFolderPath )
  2. % Figure_2.m reproduces Figure 2 in the dataset publication
  3. % fig = Figure_2(strNIXFolderPath) reproduces Figure 2
  4. % strNIXFolderPath is the path of the folder with NIX files
  5. % fig is the figure handle
  6. %
  7. % Add the toolbox 'gramm' to the MATLAB path
  8. % The toolbox can be downloaded from https://github.com/piermorel/gramm
  9. %
  10. % Add the toolbox 'FieldTrip' to the MATLAB path
  11. % The toolbox can be downloaded from http://www.fieldtriptoolbox.org/download
  12. chs = [1 3 5 6 8 10 12]; % healthy amygdalae
  13. chtot = 0;
  14. for nSubject = 1:9
  15. file_name = sprintf('Data_Subject_%.2d_Session_01.h5',nSubject);
  16. f = nix.File([strNIXFolderPath filesep file_name],nix.FileMode.ReadOnly);
  17. sectionSession = f.openSection('Session');
  18. all_trials = sectionSession.openProperty('Number of trials').values{1}.value;
  19. block = f.blocks{1};
  20. group_iEEG = block.openGroup('iEEG data');
  21. dataMacro = [];
  22. for nTrial = 1:all_trials
  23. dataArray_iEEG = group_iEEG.dataArrays{nTrial};
  24. striEEGLabels = dataArray_iEEG.dimensions{1}.labels;
  25. tiEEG = (0:(double(max(dataArray_iEEG.dataExtent))-1))* ...
  26. dataArray_iEEG.dimensions{2}.samplingInterval ...
  27. + dataArray_iEEG.dimensions{2}.offset;
  28. data_iEEG = dataArray_iEEG.readAllData;
  29. dataMacro.time{1,nTrial} = tiEEG;
  30. dataMacro.trial{1,nTrial} = data_iEEG;
  31. end
  32. dataMacro.label = striEEGLabels';
  33. dataMacro.fsample = 2000;
  34. %% Power spectrum with FieldTrip
  35. cfg = [];
  36. cfg.output = 'pow';
  37. cfg.method = 'mtmconvol';
  38. cfg.taper = 'hanning';
  39. cfg.keeptrials = 'yes';
  40. cfg.foi = logspace(log10(1),log10(100),30);
  41. cfg.foi = linspace( 1, 100 ,50);
  42. cfg.t_ftimwin = 5./cfg.foi; % length of time window = 0.5 sec
  43. cfg.toi = -5:0.1:24;
  44. cfg.trials = 2:2:17;
  45. TFR_face = ft_freqanalysis(cfg, dataMacro);
  46. cfg.trials = 1:2:17;
  47. TFR_land = ft_freqanalysis(cfg, dataMacro );
  48. ch = 1:length(TFR_land.label);
  49. tt = TFR_land.time;
  50. ff = TFR_land.freq;
  51. pwr_face = squeeze(nanmean(TFR_face.powspctrm(:,ch,:,:)));
  52. pwr_land = squeeze(nanmean(TFR_land.powspctrm(:,ch,:,:)));
  53. psd_face = nanmean(pwr_face,length(size(pwr_face)));
  54. psd_land = nanmean(pwr_land,length(size(pwr_land)));
  55. PSD_face(chtot+ch,:) = psd_face;
  56. PSD_land(chtot+ch,:) = psd_land;
  57. chtot = chtot+ch(end);
  58. end
  59. %% Plot Figure 2
  60. fig = figure;
  61. data = [PSD_face(chs,:); PSD_land(chs,:)];
  62. cval = {'Aversive' 'Neutral'};
  63. cind = [ones(chtot/2,1)*1;ones(chtot/2,1)*2];
  64. c = cval(cind);
  65. g = gramm('x',ff,'y',data,'color',c);
  66. custom_statfun = @(y)([10*log10(nanmean(y));
  67. 10*log10(nanmean(y)) - nanstd(10*log10(nanmean(y)))/sqrt(8*6);
  68. 10*log10(nanmean(y)) + nanstd(10*log10(nanmean(y)))/sqrt(8*6)]);
  69. g.stat_summary('setylim', true, 'type', custom_statfun);
  70. g.set_names( 'x', 'Frequency [Hz]', 'y', 'Power [dB]' );
  71. g.draw();
  72. print('-dtiff','-r300','fig_2.tiff')
  73. end