11using Revise
22using ElectroPhysiology
33using PhysiologyPlotting
4- PhysiologyPlotting . frontend
4+
55import ElectroPhysiology. create_signal_waveform!
66using Pkg; Pkg. activate (" test" )
77using GLMakie
8+ using PhysiologyAnalysis
89# using Pkg; Pkg.activate("test")
910
10- # We want to plot images
11- file_loc = " G:/Data/Two Photon"
12- data2P_fn = " $(file_loc) /2024_09_03_SWCNT_VGGC6/swcntBATH_kpuff_nomf_20um001.tif"
13- data2P = readImage (data2P_fn);
1411
15- xlims = data2P . HeaderDict[ " xrng " ]
16- ylims = data2P . HeaderDict[ " yrng " ]
17- deinterleave! (data2P) # This seperates the movies into two seperate movies
12+ # ╔═╡This task is for extraction of points, centroids, and ROIs using cellpose
13+ img_fn = raw " F: \D ata \T wo Photon \2 025-05-02-GRAB-DA-nirCAT-STR \g rab-nircat-str-kpuff_3x012.tif "
14+ stim_fn = raw " F: \D ata \P atching \2 025-05-02-GRAB-DA-STR \2 5502017.abf "
1815
19- val = Observable (xlims)
20- minimum (val[])
16+ # We should look through the available files and see which ones fit
17+ img_fn = raw " F:\D ata\T wo Photon\2 025-05-02-GRAB-DA-nirCAT-STR\g rab-nircat-str-20hz-100uA001.tif"
18+ stim_fn = raw " F:\D ata\P atching\2 025-05-02-GRAB-DA-STR\2 5502000.abf"
2119
22- PhysiologyPlotting. __init__ ()
23- twophotonprojection (data2P, dims = (1 , 2 ), channel = 2 )
24- twophotonframe (data2P, 1 , channel = 2 )
25-
26- # %%
27- fig = Figure (figsize = (800 , 800 ))
28- ax1 = Axis (fig[1 ,1 ], aspect = 1.0 , title = " Frame 1" )
29- frame = Observable (1 )
30- tp = twophotonframe! (ax1, data2P, frame, channel = 2 , colorrange = (0.0 , 0.02 ))
31- fig
32- record (fig, " test/test.mp4" , enumerate (data2P. t)) do (i, t)
33- println (i)
34- tp. frame[] = i
35- ax1. title = " Frame $i "
36- end
37- # %%
20+ # We should look through the available files and see which ones fit
21+ img_fn = raw " F:\D ata\T wo Photon\2 025-05-02-GRAB-DA-nirCAT-STR\g rab-nircat-str-20hz-100uA001.tif"
22+ stim_fn = raw " F:\D ata\P atching\2 025-05-02-GRAB-DA-STR\2 5502000.abf"
3823
39- # %%
40- img_arr = get_all_frames (data2P)
41- grn_zstack = img_arr[:,:,:,1 ]
42- grn_zproj = project (data2P, dims = (3 ))[:,:,1 ,1 ]
43- grn_trace = project (data2P, dims = (1 ,2 ))[1 ,1 ,:,1 ]
44-
45- red_zstack = img_arr[:,:,:,2 ]
46- red_zproj = project (data2P, dims = (3 ))[:,:,1 ,2 ]
47- red_trace = project (data2P, dims = (1 ,2 ))[1 ,1 ,:,2 ]
24+ data2P = readImage (img_fn);
25+ deinterleave! (data2P) # This seperates the movies into two seperate movies
4826
49- # %% Plot the figure
50- fig = Figure (size = (1000 , 800 ))
51- ax1a = GLMakie. Axis (fig[1 ,1 ], title = " Green Channel" , aspect = 1.0 )
52- ax1b = GLMakie. Axis (fig[2 ,1 ], title = " Red Channel" , aspect = 1.0 )
27+ spike_train = true
28+ if spike_train
29+ # If we have a electrical stimulus we need to do the spike train analysis
30+ addStimulus! (data2P, stim_fn, " IN 3" , flatten_episodic = true , stimulus_threshold = 0.5 )
31+ stim_protocol = getStimulusProtocol (data2P)
32+ spike_train_group! (stim_protocol, 3.0 )
33+ else
34+ # Else we can just use the stimulus to get the time of the stimulus
35+ addStimulus! (data2P, stim_fn, " IN 2" , flatten_episodic = true )
36+ time2P = data2P. t
37+ end
5338
54- ax2a = GLMakie . Axis (fig[ 1 , 2 ], title = " Green Trace " ) # , aspect = 1.0)
55- ax2b = GLMakie . Axis (fig[ 2 , 2 ], title = " Red Trace " ) # , aspect = 1.0 )
39+ # Split the image into 8x8 pixel ROIs
40+ pixel_splits_roi! (data2P, 8 )
5641
57- mu_grn = mean (grn_zstack)
58- sig_grn = std (grn_zstack)* 2
42+ # Process all ROIs for channel 2 and stimulus 2
43+ roi_analysis = process_rois (data2P;
44+ channels= [1 , 2 ], # Only process channel 2
45+ stim_indices= nothing , # Only process the second stimulus
46+ delay_time= 50.0 , # 50ms delay time for analysis
47+ sig_window= 50.0 , # 50ms window to look for significant responses after stimulus
48+ window = 15 , # 15-point window for moving average
49+ n_stds = 5.0 ,
50+ lam = 1e4 , # These are baselineing parameters
51+ niter = 100
52+ )
5953
60- mu_red = mean (red_zstack)
61- sig_red = std (red_zstack)* 2
54+ # Store the analysis in the experiment's HeaderDict
55+ # data2P.HeaderDict["ROI_Analysis"] = roi_analysis
56+ data2P. HeaderDict[" ROI_Analysis" ]
57+ # Get all significant ROIs and print summary
58+ sig_rois = get_significant_rois (roi_analysis)
59+ println (" Found $(length (sig_rois)) significant ROIs" )
6260
63- hm2a = heatmap! (ax1a, xlims, ylims, grn_zstack[:,:,1 ], colormap = Reverse (:algae ), colorrange = (0.0 , mu_grn + sig_grn))
64- hm2b = heatmap! (ax1b, xlims, ylims, red_zstack[:,:,1 ], colormap = :gist_heat , colorrange = (0.0 , mu_red + 2 sig_red), alpha = 1.0 )
61+ # Get fit parameters and print summary statistics
62+ fit_params = get_fit_parameters (roi_analysis)
63+ println (" Mean amplitude of significant ROIs: " , mean (first .(fit_params)))
6564
65+ fig = plot_roi_analysis (data2P, stim_idx = 2 )
66+ display (fig)
6667
6768
68- # %%
69- root = raw " F:\D ata\P atching"
70- file = " 2024_01_25_ChAT-RFP_DSGC/Cell1/24125005.abf"
71- filename = joinpath (root, file)
72- data = readABF (filename)
73- create_signal_waveform! (data, " Cmd 0" )
74- experimentplot (data)
69+ # %% Test the new simple analysis plot function
70+ PhysiologyPlotting. __init__ ()
71+ fig_raw = PhysiologyPlotting. plot_analysis (data2P)
72+ display (fig_raw)
0 commit comments