-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_spatial_visualizations.m
More file actions
102 lines (86 loc) · 4.65 KB
/
Copy pathexample_spatial_visualizations.m
File metadata and controls
102 lines (86 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
% EXAMPLE_SPATIAL_VISUALIZATIONS
%
% Demonstrates the spatial visualization additions for projecting activation,
% anatomy, and connectivity onto the probe / cortical surface:
% 1. Time-animation movies of a biomarker (MP4 / GIF)
% 2. Sensitivity-weighted cortical interpolation kernel
% 3. Anatomical (Brodmann) parcel projection
% 4. Optode parcel map (per-channel Voronoi cells, highlight + value-fill)
% 5. Brain-anchored connectome (edges drawn on the cortex / probe)
% 6. Dual-brain inter-brain synchrony with a linked wavelet panel
%
% Run top-to-bottom. File outputs are written to a temp folder and the paths
% are printed; figures are also left open for interactive inspection.
% -- Setup ----------------------------------------------------------------
outDir = fullfile(tempdir, 'pf2_spatial_viz');
if ~exist(outDir, 'dir'), mkdir(outDir); end
fprintf('Outputs -> %s\n', outDir);
procMrk = processFNIRS2(pf2.import.sampleData()); % WITH markers
proc = processFNIRS2(pf2.import.sampleData.fNIR2000()); % no markers
%% 1. Time-animation movie (3D cortex)
% Sweep HbO over time; one global color scale; time + marker stamp per frame.
mp4Path = fullfile(outDir, 'hbo_movie.mp4');
pf2.probe.plot.movie(procMrk, 'HbO', ...
'TimeRange', [0 40], 'NFrames', 80, 'FPS', 20, ...
'initCamPosition', 'front', 'savePath', mp4Path);
% 2D heatmap movie as an animated GIF
gifPath = fullfile(outDir, 'hbo_movie.gif');
pf2.probe.plot.movie(procMrk, 'HbO', 'View', '2d', ...
'TimeRange', [0 40], 'NFrames', 60, 'FPS', 15, 'savePath', gifPath);
% Same thing via the topo shortcut (delegates to movie):
pf2.probe.plot.topo(procMrk, 'HbO', 'View', 'movie', ...
'Time', [0 40], 'NFrames', 60, 'savePath', fullfile(outDir, 'topo_movie.mp4'));
%% 2. Sensitivity-weighted interpolation kernel
% Gaussian optical-sensitivity falloff (smooth) vs the default nearest/IDW.
meanHbO = mean(proc.HbO, 1, 'omitnan');
figure('Color', 'w', 'Position', [0 0 900 700]);
pf2.probe.project.biomarker(meanHbO, proc, ...
'interpolateType', 'sensitivity', ...
'initCamPosition', 'front', 'ForceLightMode', true);
title('HbO — sensitivity kernel');
%% 3. Anatomical parcel projection
% Canonicalize to a Brodmann-region axis, then flat-fill each parcel.
procC = pf2.probe.canonicalize(proc, 'MaxDistance', 25);
figure('Color', 'w', 'Position', [0 0 900 700]);
pf2.probe.project.regions('HbO', procC, ... % biomarker name -> time mean
'initCamPosition', 'front');
title('HbO — Brodmann parcels');
%% 4. Optode parcel map (per-channel Voronoi cells)
% A channel-space "parcel map": each cortical vertex is assigned to its nearest
% optode, drawn as discrete cells with smooth outlines and on-surface numbers.
% This is a channel-assignment cartoon (NOT image reconstruction/DOT): spatial
% resolution is channel-limited and the coverage radius is a display heuristic.
%
% (a) Highlight a subset of channels (numeric = printed optode numbers).
figure('Color', 'w', 'Position', [0 0 900 700]);
pf2.probe.project.parcels(proc, 'Highlight', [2 8 9 16], ...
'initCamPosition', 'front', 'savePath', fullfile(outDir, 'parcels_highlight.png'));
title('Optode parcels — highlighted subset');
% (b) Fill each cell by its channel value (a discrete per-channel map).
figure('Color', 'w', 'Position', [0 0 900 700]);
pf2.probe.project.parcels(meanHbO, proc, ...
'Colorbar', '\muM', 'initCamPosition', 'front', ...
'savePath', fullfile(outDir, 'parcels_value.png'));
title('Optode parcels — HbO per channel');
%% 5. Brain-anchored connectome
% Channel-level Pearson connectivity drawn at real optode positions.
conn = exploreFNIRS.connectivity.computeMatrix(proc, ...
'Method', 'pearson', 'Biomarker', 'HbO');
figure('Color', 'w', 'Position', [0 0 900 700]);
pf2.probe.plot.connectome(conn, proc, 'View', '3d', ...
'TopN', 30, 'initCamPosition', 'front');
figure('Color', 'w', 'Position', [0 0 1000 500]);
pf2.probe.plot.connectome(conn, proc, 'View', '2d', 'Threshold', 0.5);
%% 6. Dual-brain inter-brain synchrony
% Cross-brain coupling between two subjects (here the same recording twice),
% with a linked wavelet-coherence time-frequency panel.
A = proc; B = processFNIRS2(pf2.import.sampleData.fNIR2000());
dyad = exploreFNIRS.hyperscanning.computeDyad(A, B, ...
'Method', 'pearson', 'ChannelPairing', 'all');
% A wavelet-coherence panel for one homologous channel pair (channel 1).
wc = exploreFNIRS.coupling.wcoherence(A.HbO(:,1), B.HbO(:,1), A.fs);
exploreFNIRS.hyperscanning.plotDualBrain(dyad, A, B, ...
'TopN', 30, 'Wcoherence', wc, ...
'BrainLabels', {'Child', 'Parent'}, ...
'SavePath', fullfile(outDir, 'dualbrain.png'));
fprintf('Done. Movie/GIF/PNG outputs are in %s\n', outDir);