Skip to content

Commit 797dc1b

Browse files
committed
Update Manifest.toml and revision.jl to reflect new version and repository details for PhysiologyAnalysis.jl, and enhance data processing and ROI analysis capabilities in the revision script.
1 parent 408bba6 commit 797dc1b

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

test/Manifest.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,9 +1509,11 @@ version = "0.5.3"
15091509

15101510
[[deps.PhysiologyAnalysis]]
15111511
deps = ["CSV", "DataFrames", "Dates", "ElectroPhysiology", "FileIO", "GLMakie", "HypothesisTests", "ImageFiltering", "ImageMagick", "Images", "Interpolations", "LinearAlgebra", "LsqFit", "OffsetArrays", "Peaks", "Polynomials", "ProgressMeter", "Requires", "SparseArrays", "Statistics", "StatsBase"]
1512-
git-tree-sha1 = "6ed70263e54b8226923facb6fe94d5ccbf7f7085"
1512+
git-tree-sha1 = "fdacba89a4223af2bf2a3cb07208ad13421b404c"
1513+
repo-rev = "main"
1514+
repo-url = "https://github.com/mattar13/PhysiologyAnalysis.jl.git"
15131515
uuid = "69cbc4a0-077e-48a7-9b45-fa8b7014b5ca"
1514-
version = "0.6.32"
1516+
version = "0.6.36"
15151517

15161518
[[deps.Pixman_jll]]
15171519
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LLVMOpenMP_jll", "Libdl"]

test/revision.jl

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,72 @@
11
using Revise
22
using ElectroPhysiology
33
using PhysiologyPlotting
4-
PhysiologyPlotting.frontend
4+
55
import ElectroPhysiology.create_signal_waveform!
66
using Pkg; Pkg.activate("test")
77
using 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:\Data\Two Photon\2025-05-02-GRAB-DA-nirCAT-STR\grab-nircat-str-kpuff_3x012.tif"
14+
stim_fn = raw"F:\Data\Patching\2025-05-02-GRAB-DA-STR\25502017.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:\Data\Two Photon\2025-05-02-GRAB-DA-nirCAT-STR\grab-nircat-str-20hz-100uA001.tif"
18+
stim_fn = raw"F:\Data\Patching\2025-05-02-GRAB-DA-STR\25502000.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:\Data\Two Photon\2025-05-02-GRAB-DA-nirCAT-STR\grab-nircat-str-20hz-100uA001.tif"
22+
stim_fn = raw"F:\Data\Patching\2025-05-02-GRAB-DA-STR\25502000.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 + 2sig_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:\Data\Patching"
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

Comments
 (0)