66 session_alignment ,
77 plotting_session_alignment ,
88)
9+ from spikeinterface .widgets import plot_session_alignment , plot_activity_histogram_2d
910import matplotlib .pyplot as plt
1011
1112import spikeinterface .full as si
3132
3233 recordings_list , _ = generate_session_displacement_recordings (
3334 num_units = 65 ,
34- recording_durations = [400 , 400 , 400 ],
35+ recording_durations = [200 , 200 , 200 ],
3536 recording_shifts = ((0 , 0 ), (0 , - 200 ), (0 , 150 )), # TODO: can see how well this is recaptured by comparing the displacements to the known displacement + gradient
36- non_rigid_gradient = 0.1 , # 0.1,
37- seed = 5 , # 52
37+ non_rigid_gradient = None , # 0.1, # 0.1,
38+ seed = 55 , # 52
3839 )
3940
4041 if False :
8182 # See `session_alignment.py` for docs on these settings.
8283
8384 non_rigid_window_kwargs = session_alignment .get_non_rigid_window_kwargs ()
84- non_rigid_window_kwargs ["rigid_mode" ] = "rigid"
85- non_rigid_window_kwargs ["win_shape" ] = "rect"
86- non_rigid_window_kwargs ["win_step_um" ] = 300.0
87- non_rigid_window_kwargs ["win_scale_um" ] = 400.0
85+ non_rigid_window_kwargs ["rigid" ] = False
86+ non_rigid_window_kwargs ["num_shifts_global" ] = 500
87+ non_rigid_window_kwargs ["num_shifts_block" ] = 24 # TODO: it makes no sense for this to be larger than the window
88+ non_rigid_window_kwargs ["win_step_um" ] = 125
89+ non_rigid_window_kwargs ["win_scale_um" ] = 60
8890
8991 estimate_histogram_kwargs = session_alignment .get_estimate_histogram_kwargs ()
9092 estimate_histogram_kwargs ["method" ] = "chunked_median"
91- estimate_histogram_kwargs ["histogram_type" ] = "activity_1d " # TODO: investigate this case thoroughly
92- estimate_histogram_kwargs ["bin_um" ] = 5
93- estimate_histogram_kwargs ["log_scale" ] = False
94- estimate_histogram_kwargs ["weight_with_amplitude" ] = True
93+ estimate_histogram_kwargs ["histogram_type" ] = "activity_2d " # TODO: investigate this case thoroughly
94+ estimate_histogram_kwargs ["bin_um" ] = 2
95+ estimate_histogram_kwargs ["log_scale" ] = True
96+ estimate_histogram_kwargs ["weight_with_amplitude" ] = False
9597
9698 compute_alignment_kwargs = session_alignment .get_compute_alignment_kwargs ()
97- compute_alignment_kwargs ["num_shifts_block " ] = 300
99+ compute_alignment_kwargs ["interpolate " ] = False
98100
99101 corrected_recordings_list , extra_info = session_alignment .align_sessions (
100102 recordings_list ,
103105 alignment_order = "to_session_1" , # "to_session_X" or "to_middle"
104106 non_rigid_window_kwargs = non_rigid_window_kwargs ,
105107 estimate_histogram_kwargs = estimate_histogram_kwargs ,
108+ compute_alignment_kwargs = compute_alignment_kwargs ,
106109 )
107- # si.plot_traces(recordings_list[0], mode="line", time_range=(0, 1))
108- # plt.show()
109110
110- # TODO: nonlinear is not working well 'to middle', investigate
111- # TODO: also finalise the estimation of bin number of nonrigid.
112-
113- if False :
114- plt .plot (extra_info ["histogram_info_list" ][0 ]["chunked_histograms" ].T , color = "black" )
115-
116- M = extra_info ["session_histogram_list" ][0 ]
117- S = extra_info ["histogram_info_list" ][0 ]["session_histogram_variation" ]
118-
119- plt .plot (M , color = "red" )
120- plt .plot (M + S , color = "green" )
121- plt .plot (M - S , color = "green" )
122-
123- plt .show ()
124-
125- plotting_session_alignment .SessionAlignmentWidget (
111+ plot_session_alignment (
126112 recordings_list ,
127113 peaks_list ,
128114 peak_locations_list ,
131117 spatial_bin_centers = extra_info ["spatial_bin_centers" ],
132118 drift_raster_map_kwargs = {"clim" :(- 250 , 0 ), "scatter_decimate" : 10 }
133119 )
134-
135120 plt .show ()
136121
137- np .save ("histogram1.npy" , extra_info ["session_histogram_list" ][0 ])
138- np .save ("histogram2.npy" , extra_info ["session_histogram_list" ][1 ])
139- np .save ("histogram3.npy" , extra_info ["session_histogram_list" ][2 ])
140- breakpoint ()
122+ if estimate_histogram_kwargs ["histogram_type" ] == "activity_2d" :
123+ plot_activity_histogram_2d (
124+ extra_info ["session_histogram_list" ],
125+ extra_info ["spatial_bin_centers" ],
126+ extra_info ["corrected" ]["corrected_session_histogram_list" ]
127+ )
128+ plt .show ()
0 commit comments