|
30 | 30 | raw_intensity = mne.io.read_raw_nirx(fnirs_cw_amplitude_dir, verbose=True) |
31 | 31 | raw_intensity.load_data() |
32 | 32 |
|
33 | | - |
34 | 33 | # %% |
35 | 34 | # Providing more meaningful annotation information |
36 | 35 | # ------------------------------------------------ |
|
48 | 47 | unwanted = np.nonzero(raw_intensity.annotations.description == "15.0") |
49 | 48 | raw_intensity.annotations.delete(unwanted) |
50 | 49 |
|
51 | | - |
52 | 50 | # %% |
53 | 51 | # Viewing location of sensors over brain surface |
54 | 52 | # ---------------------------------------------- |
|
89 | 87 | n_channels=len(raw_intensity.ch_names), duration=500, show_scrollbars=False |
90 | 88 | ) |
91 | 89 |
|
92 | | - |
93 | 90 | # %% |
94 | 91 | # Converting from raw intensity to optical density |
95 | 92 | # ------------------------------------------------ |
|
99 | 96 | raw_od = mne.preprocessing.nirs.optical_density(raw_intensity) |
100 | 97 | raw_od.plot(n_channels=len(raw_od.ch_names), duration=500, show_scrollbars=False) |
101 | 98 |
|
102 | | - |
103 | 99 | # %% |
104 | 100 | # Evaluating the quality of the data |
105 | 101 | # ---------------------------------- |
|
118 | 114 | ax.hist(sci) |
119 | 115 | ax.set(xlabel="Scalp Coupling Index", ylabel="Count", xlim=[0, 1]) |
120 | 116 |
|
121 | | - |
122 | 117 | # %% |
123 | 118 | # In this example we will mark all channels with a SCI less than 0.5 as bad |
124 | 119 | # (this dataset is quite clean, so no channels are marked as bad). |
125 | 120 |
|
126 | 121 | raw_od.info["bads"] = list(compress(raw_od.ch_names, sci < 0.5)) |
127 | 122 |
|
128 | | - |
129 | 123 | # %% |
130 | 124 | # At this stage it is appropriate to inspect your data |
131 | 125 | # (for instructions on how to use the interactive data visualisation tool |
|
134 | 128 | # If your data contains lots of artifacts you may decide to apply |
135 | 129 | # artifact reduction techniques as described in :ref:`ex-fnirs-artifacts`. |
136 | 130 |
|
137 | | - |
138 | 131 | # %% |
139 | 132 | # Converting from optical density to haemoglobin |
140 | 133 | # ---------------------------------------------- |
|
145 | 138 | raw_haemo = mne.preprocessing.nirs.beer_lambert_law(raw_od, ppf=0.1) |
146 | 139 | raw_haemo.plot(n_channels=len(raw_haemo.ch_names), duration=500, show_scrollbars=False) |
147 | 140 |
|
148 | | - |
149 | 141 | # %% |
150 | 142 | # Removing heart rate from signal |
151 | 143 | # ------------------------------- |
|
178 | 170 | events, event_dict = mne.events_from_annotations(raw_haemo) |
179 | 171 | fig = mne.viz.plot_events(events, event_id=event_dict, sfreq=raw_haemo.info["sfreq"]) |
180 | 172 |
|
181 | | - |
182 | 173 | # %% |
183 | 174 | # Next we define the range of our epochs, the rejection criteria, |
184 | 175 | # baseline correction, and extract the epochs. We visualize the log of which |
|
203 | 194 | ) |
204 | 195 | epochs.plot_drop_log() |
205 | 196 |
|
206 | | - |
207 | 197 | # %% |
208 | 198 | # View consistency of responses across trials |
209 | 199 | # ------------------------------------------- |
|
221 | 211 | ts_args=dict(ylim=dict(hbo=[-15, 15], hbr=[-15, 15])), |
222 | 212 | ) |
223 | 213 |
|
224 | | - |
225 | 214 | # %% |
226 | 215 | # We can also view the epoched data for the control condition and observe |
227 | 216 | # that it does not show the expected morphology. |
|
233 | 222 | ts_args=dict(ylim=dict(hbo=[-15, 15], hbr=[-15, 15])), |
234 | 223 | ) |
235 | 224 |
|
236 | | - |
237 | 225 | # %% |
238 | 226 | # View consistency of responses across channels |
239 | 227 | # --------------------------------------------- |
|
250 | 238 | for ax in axes[:, column]: |
251 | 239 | ax.set_title(f"{condition}: {ax.get_title()}") |
252 | 240 |
|
253 | | - |
254 | 241 | # %% |
255 | 242 | # Plot standard fNIRS response image |
256 | 243 | # ---------------------------------- |
|
277 | 264 | evoked_dict, combine="mean", ci=0.95, colors=color_dict, styles=styles_dict |
278 | 265 | ) |
279 | 266 |
|
280 | | - |
281 | 267 | # %% |
282 | 268 | # View topographic representation of activity |
283 | 269 | # ------------------------------------------- |
|
290 | 276 | times=times, topomap_args=topomap_args |
291 | 277 | ) |
292 | 278 |
|
293 | | - |
294 | 279 | # %% |
295 | 280 | # Compare tapping of left and right hands |
296 | 281 | # --------------------------------------- |
|
0 commit comments