fig1S1.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. """Fig 1S1 plots"""
  2. # import
  3. from djd.signal import rfs_for_cdata, optosupp_for_cdata
  4. from djd.plot import simple_plot_rfs, simple_plot_optosupp
  5. import matplotlib.pyplot as plt
  6. # specify and update matplotlib parameters
  7. fontsize = 6.4
  8. params = {
  9. 'font.family': 'FreeSans',
  10. 'font.weight': 'normal',
  11. 'font.size': fontsize,
  12. 'pdf.fonttype': 42,
  13. 'ps.fonttype': 42,
  14. 'xtick.labelsize': fontsize,
  15. 'ytick.labelsize': fontsize,
  16. 'lines.linewidth' :0.734,
  17. 'xtick.major.size' : 1.734,
  18. 'ytick.major.size' : 1.734,
  19. 'axes.linewidth' : 0.4,
  20. 'axes.titlesize': fontsize,
  21. 'ytick.major.width' :0.4,
  22. 'xtick.major.width' :0.4,
  23. 'savefig.dpi': 300,
  24. }
  25. plt.rcParams.update(params)
  26. # optosuppression panel
  27. # define key and target channels
  28. v1key = {'m': 'PVCre_2018_0003', 's': 1, 'e': 1}
  29. exchanis = [24, 25, 26]
  30. # get opto suppression data
  31. ondata, offdata, t, stim_perc_red, light_diff_onset, light_dur, stim_dur = optosupp_for_cdata(
  32. key=v1key,
  33. pad=(-0.2, 1))
  34. # init parameters
  35. cmpin = 2.54
  36. figwidth = 11.4 / cmpin
  37. figheight = 15 / cmpin
  38. bardistance = 1.2 # distance bar to axes
  39. barwidth = 3
  40. chanh = 0.15 # subplot height
  41. interchanh = 0.038 # vertical space between subplots
  42. figsize = (figwidth, figheight)
  43. f = plt.figure(figsize=figsize)
  44. # define first axis
  45. l1 = 0.07
  46. b1 = 0.61
  47. w1 = 0.6
  48. h = chanh
  49. # create axis for each channel
  50. axlist = []
  51. for _ in exchanis:
  52. b1 = b1 - chanh
  53. ax = f.add_axes([l1, b1, w1, h])
  54. b1 = b1 - interchanh
  55. axlist.append(ax)
  56. # fill axes with data
  57. axs = simple_plot_optosupp(key=v1key, ondata=ondata, offdata=offdata, t=t, perc_red=stim_perc_red,
  58. light_diff_onset=light_diff_onset, light_dur=light_dur,
  59. stim_dur=stim_dur, barwidth=barwidth, bardistance=bardistance,
  60. axs=axlist, chanis=exchanis)
  61. # format figure
  62. axs[1].set_ylabel('Normalized multi unit activity')
  63. axs[-1].set_ylabel('')
  64. axs[-1].set_xticklabels((0,1,2,3))
  65. # rf panel
  66. # define keys for the two mua rfs
  67. ekeys = [{'m': 'PVCre_2017_0015', 's': 3, 'e':1},
  68. {'m': 'PVCre_2017_0015', 's': 7, 'e':1}]
  69. # define analysis window
  70. rf_offset = (0.05, 0.1)
  71. # init parameters
  72. chanh = 0.04 # subplot height
  73. interchanh = 0.025 # vertical space between subplots
  74. w = 0.18
  75. h = chanh
  76. start_chans = [7,14] # indices of channels to start from (one for each key)
  77. nchans = 8 # number of channels to plot
  78. sep = 2 # step: plot every second channel
  79. # create one axis per channel
  80. axlists=[]
  81. for k in range(2):
  82. axlist=[]
  83. l = l1 + w1 + 0.1 + (0.1 * k)
  84. b2 = 0.61
  85. for i in range(nchans):
  86. b2 = b2 - chanh
  87. ax = f.add_axes([l, b2, w, h])
  88. b2 = b2 - interchanh
  89. axlist.append(ax)
  90. axlists.append(axlist)
  91. # fill axes with data
  92. for ekey, axlist, start_chan in zip(ekeys, axlists, start_chans):
  93. rfs, axes, chorder = rfs_for_cdata(ekey, offset=rf_offset)
  94. simple_plot_rfs(ekey, rfs[start_chan:start_chan+(nchans*sep):sep,:,:,:],
  95. axes, interpolation='spline16', nrows=nchans,
  96. chorder=chorder[start_chan:start_chan+(nchans*sep)],
  97. axs=axlist, contrasts=2)
  98. for ax in axlist:
  99. ax.set_title((''))
  100. # format figure
  101. axlists[0][-1].yaxis.tick_left()
  102. axlists[0][-1].set_ylabel('Elevation')
  103. axlists[0][-1].set_xlabel('Azimuth')
  104. axlists[1][-1].set_yticklabels((''))
  105. axlists[0][0].set_title('Exp1')
  106. axlists[1][0].set_title('Exp2')