|
112 | 112 | plt.show() |
113 | 113 |
|
114 | 114 | ############################################################################### |
115 | | -# We see that many voxels have low explainable variance. This is |
| 115 | +# We see that many voxels have low explainable variance. This is |
116 | 116 | # expected, since many voxels are not driven by a visual stimulus, and their |
117 | 117 | # response changes over repeats of the same stimulus. |
118 | 118 | # We also see that some voxels have high explainable variance (around 0.7). The |
|
171 | 171 | # The second mapper we provide maps the voxel data to a Freesurfer |
172 | 172 | # average surface ("fsaverage"), that can be used in ``pycortex``. |
173 | 173 | # |
174 | | -# If you are running the notebook on Colab, you might need to update the |
175 | | -# pycortex filestore as following: |
| 174 | +# First, let's download the "fsaverage" surface. |
176 | 175 |
|
177 | 176 | import cortex |
178 | | -try: |
179 | | - import google.colab # noqa |
180 | | - in_colab = True |
181 | | -except ImportError: |
182 | | - in_colab = False |
183 | | -print(in_colab) |
184 | | - |
185 | | -if in_colab: |
186 | | - filestore = cortex.options.config['basic']['filestore'] |
187 | | - cortex.database.db = cortex.database.Database(filestore) |
188 | | - cortex.db = cortex.database.db |
189 | | - cortex.utils.db = cortex.database.db |
190 | | - cortex.dataset.braindata.db = cortex.database.db |
191 | | - cortex.quickflat.utils.db = cortex.database.db |
192 | | - cortex.quickflat.composite.db = cortex.database.db |
193 | | - |
194 | | -############################################################################### |
195 | | -# Now, let's download the "fsaverage" surface. |
196 | 177 |
|
197 | 178 | surface = "fsaverage" |
198 | 179 |
|
199 | 180 | if not hasattr(cortex.db, surface): |
200 | | - cortex.utils.download_subject(subject_id=surface) |
201 | | - # reinitialize pycortex's database to update available subjects |
202 | | - filestore = cortex.options.config['basic']['filestore'] |
203 | | - cortex.database.db = cortex.database.Database(filestore) |
204 | | - cortex.db = cortex.database.db |
205 | | - cortex.utils.db = cortex.database.db |
206 | | - cortex.dataset.braindata.db = cortex.database.db |
207 | | - cortex.quickflat.utils.db = cortex.database.db |
208 | | - cortex.quickflat.composite.db = cortex.database.db |
| 181 | + cortex.utils.download_subject(subject_id=surface, |
| 182 | + pycortex_store=cortex.db.filestore) |
| 183 | + cortex.db._subjects = None # force filestore reload |
| 184 | + assert hasattr(cortex.db, surface) |
209 | 185 |
|
210 | 186 | ############################################################################### |
211 | 187 | # Then, we load the "fsaverage" mapper. The mapper is a matrix of shape |
|
228 | 204 |
|
229 | 205 | ############################################################################### |
230 | 206 | # To start an interactive 3D viewer in the browser, we can use the ``webshow`` |
231 | | -# function in pycortex. |
232 | | -# If you are running the notebook on Colab, you first need to tunnel the pycortex |
233 | | -# application out of Colab. To do so, use the following cell to start a tunnel |
234 | | -# with ``ngrok`` and to get an address where the pycortex viewer will be made |
235 | | -# accessible. |
| 207 | +# function in pycortex. If you are running the notebook on Colab, you first |
| 208 | +# need to tunnel the pycortex application out of Colab. To do so, use the |
| 209 | +# following cell to start a tunnel with ``ngrok`` and to get an address where |
| 210 | +# the pycortex viewer will be made accessible. |
| 211 | + |
| 212 | +try: |
| 213 | + import google.colab # noqa |
| 214 | + in_colab = True |
| 215 | +except ImportError: |
| 216 | + in_colab = False |
| 217 | +print(in_colab) |
236 | 218 |
|
237 | 219 | if in_colab: |
238 | 220 | from IPython import get_ipython |
|
248 | 230 | f"{result}\n" |
249 | 231 | "and not the one proposed by pycortex ('Open viewer: ...')\n") |
250 | 232 |
|
251 | | - |
252 | 233 | ############################################################################### |
253 | 234 | # Now you can start an interactive 3D viewer by changing ``run_webshow`` to |
254 | 235 | # ``True`` and running the following cell. If you are using Colab, remember to |
|
272 | 253 | with_rois=has_installed("inkscape")) |
273 | 254 | plt.show() |
274 | 255 |
|
275 | | - |
276 | 256 | ############################################################################### |
277 | 257 | # References |
278 | 258 | # ---------- |
|
0 commit comments