@@ -333,6 +333,15 @@ function plot_analysis(data::Experiment{TWO_PHOTON, T};
333333 # ax average should be 1/4 the width of ax
334334 colsize! (fig. layout, 2 , Relative (0.25 ))
335335
336+ # Link y-axes
337+ linkyaxes! (ax, ax_average)
338+
339+ # Remove grid and axes
340+ # hidespines!(ax)
341+ # hidedecorations!(ax)
342+ # hidespines!(ax_average)
343+ # hidedecorations!(ax_average)
344+
336345 # Get z-profile trace for this channel (mean intensity over time)
337346 z_profile = project (data, dims= (1 ,2 ))[1 ,1 ,:,channel]
338347 baseline_trace = PhysiologyAnalysis. baseline_trace (z_profile,
@@ -358,10 +367,44 @@ function plot_analysis(data::Experiment{TWO_PHOTON, T};
358367 delay_time = haskey (analysis. analysis_parameters, :delay_time ) ? analysis. analysis_parameters[:delay_time ] : nothing
359368 vlines! (ax_average, [delay_time], color= :black , linestyle= :dash )
360369
370+ # Add x and y scale bars to lower left of raw trace axis
371+ if channel == 1
372+ xbar_length = 25.0 # seconds
373+ ybar_length = 0.1 # adjust to your data's scale
374+
375+ x0 = 40.0 # minimum(time_axis) + 0.05 * (maximum(time_axis) - minimum(time_axis))
376+ y0 = 0.005 # minimum(baseline_trace) + 0.1 * (maximum(baseline_trace) - minimum(baseline_trace))
377+ # x scale bar
378+ lines! (ax, [x0, x0 + xbar_length], [y0, y0], color= :black , linewidth= 3 )
379+ text! (ax, " $xbar_length s" , position= (x0 + xbar_length/ 2 , y0 - 0.1 * ybar_length), align= (:center , :center ), color= :black )
380+
381+ lines! (ax_average, [x0, x0 + xbar_length], [y0, y0], color= :black , linewidth= 3 )
382+ text! (ax_average, " $xbar_length s" , position= (x0 + xbar_length/ 2 , y0 - 0.1 * ybar_length), align= (:center , :center ), color= :black )
383+
384+ lines! (ax, [x0, x0], [y0, y0 + ybar_length], color= :black , linewidth= 3 )
385+ text! (ax, " $ybar_length " , position= (x0 - 0.1 * xbar_length, y0 + ybar_length/ 2 ), align= (:center , :center ), color= :black )
386+ else # y scale bar
387+ xbar_length = 25.0 # seconds
388+ ybar_length = 0.01 # adjust to your data's scale
389+
390+ x0 = 40.0 # minimum(time_axis) + 0.05 * (maximum(time_axis) - minimum(time_axis))
391+ y0 = 0.005 # minimum(baseline_trace) + 0.1 * (maximum(baseline_trace) - minimum(baseline_trace))
392+
393+ lines! (ax, [x0, x0 + xbar_length], [y0, y0], color= :black , linewidth= 3 )
394+ text! (ax, " $xbar_length s" , position= (x0 + xbar_length/ 2 , y0 - 0.1 * ybar_length), align= (:center , :center ), color= :black )
395+
396+ lines! (ax_average, [x0, x0 + xbar_length], [y0, y0], color= :black , linewidth= 3 )
397+ text! (ax_average, " $xbar_length s" , position= (x0 + xbar_length/ 2 , y0 - 0.1 * ybar_length), align= (:center , :center ), color= :black )
398+
399+ lines! (ax, [x0, x0], [y0, y0 + ybar_length], color= :black , linewidth= 3 )
400+ text! (ax, " $ybar_length " , position= (x0 - 0.1 * xbar_length, y0 + ybar_length/ 2 ), align= (:center , :center ), color= :black )
401+ end
402+
361403 # Add stimulus lines if available
362404 if haskey (data. HeaderDict, " StimulusProtocol" )
363405 stim_protocol = data. HeaderDict[" StimulusProtocol" ]
364- println (stim_protocol)
406+ stim_end_times = getStimulusEndTime (stim_protocol)
407+ vlines! (ax, stim_end_times, color= :black , linestyle= :dash , alpha = 0.5 )
365408 end
366409 end
367410
0 commit comments