cosanlab / nltools

Python toolbox for analyzing imaging data
https://nltools.org
MIT License
122 stars 44 forks source link

Indexing issues with Brain_Data and Adjacency #318

Closed ejolly closed 4 years ago

ejolly commented 5 years ago

@ljchang I've encountered a weird issue in both Brain_Data and Adjacency when I try to index with a boolean mask that contains a single True value. What I would expect is to get bad a 1d Brain_Data or a 1d Adjacency, e.g.

mask = [True, False, False] # I want back the first instance
brain = Brain_Data(...) # 3 images
out = brain[mask]
out.shape() # (1, numvox) but should be (numvox)

# Same thing happens with Adjacency

This is really annoying because it messes up how several methods behavior e.g. out.similarity(other_brain) throws a dimension mismatch error for both classes.

Maybe you need to add another type check in the __getitem__ to deal with this?

ljchang commented 4 years ago

@ejolly: I can't replicate this, maybe it already got fixed with another issue?

Screen Shot 2020-04-14 at 11 18 38 AM

ejolly commented 4 years ago

Yea I just tested it locally as well and looks like it's working as expected now.