detect_stages_n2.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码
def plot_aligned(data_all, transitions, label = 'data', dt = time_bin, phase = 0):
  phase_names = ['hatch', 'L1', 'L2', 'L3', 'L4', 'L5'];

  ttref0 = np.max(transitions[:, 0]);
  ntt = data_all.shape[1] + ttref0 + 500;
  nw = data_all.shape[0];

  tr = phase;
  data_algn = np.zeros((nw, ntt));
  tref = np.max(transitions[:, tr]);
  for wid in range(nworms):
    tt = transitions[wid, tr];
    ts =  transitions[wid, 0];
    te =  transitions[wid, -1];      
    nt = te - ts;
    t0 = ts + tref - tt;
    t1 = t0 + nt;
    #print 'tref=%s, ts =%d, te=%d, tt =%d, nt = %d, t0=%d, t1=%d, ntt=%d' % (tref, ts,te,tt, nt, t0,t1, ntt)
    data_algn[wid, t0 : t1] = data_all[wid,  ts:te];

  #rmax = np.nanpercentile(roam_24hr, 95); 
  rmax = 1;
  plt.imshow(data_algn, interpolation = 'none', aspect = 'auto', cmap = plt.cm.viridis, vmax = rmax )
  cb = plt.colorbar(fraction = 0.025, shrink = 0.5, pad = 0.01)
  cb.ax.set_ylabel(label + ' [au]', rotation=270, labelpad = 20)

  days = np.array(24. * 60 * 60 / time_bin * np.arange(6), dtype = int);
  labl = ['%d'%d for d  in 24 *np.linspace(0,5, 6)];  
  plt.xticks(days, labl);
  plt.xlabel('time [hrs]');   
  plt.ylabel('worm id');
  plt.tight_layout()

  plt.title(phase_names[tr]);
  plt.tight_layout()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号