Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix extents for passive plots #104

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions atlaselectrophysiology/plot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,6 @@ def gain2level(gain):
else:
h = neuropixel.trace_header(sr.major_version, nshank=np.unique(th['shank']).size)

idx = np.isin(h['ind'], th['ind'])
for k in h.keys():
h[k] = h[k][idx]

s0 = t * sr.fs
tsel = slice(int(s0), int(s0) + int(1 * sr.fs))
raw = sr[tsel, :-sr.nsync].T
Expand Down Expand Up @@ -513,21 +509,24 @@ def get_rfmap_data(self):
(rf_map_times, rf_map_pos,
rf_stim_frames) = passive.get_on_off_times_and_positions(self.data['rf_map'])

chn_min = np.min(np.r_[self.chn_min, self.data['spikes']['depths'][self.spike_idx][self.kp_idx]])
chn_max = np.max(np.r_[self.chn_max, self.data['spikes']['depths'][self.spike_idx][self.kp_idx]])

rf_map, _ = \
passive.get_rf_map_over_depth(rf_map_times, rf_map_pos, rf_stim_frames,
self.data['spikes']['times'][self.spike_idx][self.kp_idx],
self.data['spikes']['depths'][self.spike_idx][self.kp_idx],
d_bin=160)
d_bin=160, y_lim=[chn_min, chn_max])
rfs_svd = passive.get_svd_map(rf_map)
img = dict()
img['on'] = np.vstack(rfs_svd['on'])
img['off'] = np.vstack(rfs_svd['off'])
yscale = ((np.max(self.chn_coords[:, 1]) - np.min(
self.chn_coords[:, 1])) / img['on'].shape[0])
yscale = ((self.chn_max - self.chn_min) / img['on'].shape[0])

xscale = 1
levels = np.quantile(np.c_[img['on'], img['off']], [0, 1])

depths = np.linspace(0, 3840, len(rfs_svd['on']) + 1)
depths = np.linspace(self.chn_min, self.chn_max, len(rfs_svd['on']) + 1)

sub_type = ['on', 'off']
for sub in sub_type:
Expand Down Expand Up @@ -561,19 +560,21 @@ def get_passive_events(self):
stims = {stim_type: self.data['pass_stim'][stim_type] for stim_type in stim_types[0:3]}
stims.update(self.data['gabor'])

chn_min = np.min(np.r_[self.chn_min, self.data['spikes']['depths'][self.spike_idx][self.kp_idx]])
chn_max = np.max(np.r_[self.chn_max, self.data['spikes']['depths'][self.spike_idx][self.kp_idx]])

base_stim = 1
pre_stim = 0.4
post_stim = 1
stim_events = passive.get_stim_aligned_activity(stims, self.data['spikes']['times'][self.spike_idx]
[self.kp_idx], self.data['spikes']['depths']
[self.spike_idx][self.kp_idx],
pre_stim=pre_stim, post_stim=post_stim,
base_stim=base_stim)
base_stim=base_stim, y_lim=[chn_min, chn_max])

for stim_type, z_score in stim_events.items():
xscale = (post_stim + pre_stim) / z_score.shape[1]
yscale = ((np.max(self.chn_coords[:, 1]) - np.min(
self.chn_coords[:, 1])) / z_score.shape[0])
yscale = ((self.chn_max - self.chn_min) / z_score.shape[0])

levels = [-10, 10]

Expand Down
Loading