Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot.brain.brain(roi) crashes immediately #65

Open
CiaranMStone opened this issue Dec 6, 2023 · 2 comments
Open

plot.brain.brain(roi) crashes immediately #65

CiaranMStone opened this issue Dec 6, 2023 · 2 comments

Comments

@CiaranMStone
Copy link

from eelbrain import *
import mne
from matplotlib import pyplot
from aphasia_experiment import e

epoch = 'fixation'
pmin = 0.05
bl = False

if epoch == 'fixation':
tstart = 1.200
tstop = 1.600
data, res = e.load_test('speak_by_TrialType', pmin=pmin, data='source', tstart=tstart, tstop=tstop, baseline=bl,
mask='wholebrain', samples=1000, make=True, epoch=epoch, return_data=True)
clusters = res.find_clusters(pmin=0.05)
data

elif epoch == 'speak':
data, res = e.load_test('speak_by_TrialType', pmin=pmin, data='source', baseline=bl,
mask='wholebrain', samples=1000, make=True, epoch=epoch, return_data=True)
clusters = res.find_clusters(pmin=0.05)
data

if epoch == 'fixation':
load_test = 'inflect_minus_naming' # inflect_minus_naming naming_minus_button inflect_minus_button

tt_res = e.load_test(load_test, pmin=pmin, data='source', tstart=tstart, tstop=tstop, baseline=bl, 
                     mask='wholebrain', samples=1000, make=True, epoch=epoch)
tt_clusters = tt_res.find_clusters(pmin=0.05, maps=True)

elif epoch == 'speak':
load_test = 'inflect_minus_button' # inflect_minus_naming naming_minus_button inflect_minus_button

tt_res = e.load_test(load_test, pmin=pmin, data='source', baseline=bl, 
                     mask='wholebrain', samples=1000, make=True, epoch=epoch)
tt_clusters = tt_res.find_clusters(pmin=0.05, maps=True)

id = 0
tt_cluster = tt_clusters[id, 'cluster']
tt_cluster

mask = tt_cluster != 0

roi = mask.any('time')

p = plot.brain.brain(roi)

#####################################

ADDING THE CODE BELOW FIXES THE ISSUE

#####################################

ndvar = roi

source = ndvar.source
x = ndvar.get_data(source.name)
if x.dtype.kind != 'b':
raise ValueError("Require NDVar of type bool, got %r" % (x.dtype,))
name = str(ndvar.name)
lh_vertices = source.lh_vertices[x[:source.lh_n]]
rh_vertices = source.rh_vertices[x[source.lh_n:]]
lh_label, rh_label = source._label((lh_vertices, rh_vertices), name, [1, 0, 0])

p = plot.brain.brain(roi)

@CiaranMStone
Copy link
Author

Well, it was working with that extra block of code a few hours ago, but now I'm getting the same crash issue as before.

@CiaranMStone
Copy link
Author

unless I include this line prior to plot.brain.brain(roi):

p = mne.viz.Brain('fsaverage', subjects_dir=e.get('mri-sdir'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant