Skip to content

Searchlight improvement - #221

Merged
mihaic merged 15 commits into
brainiak:masterfrom
mjanderson09:searchlight_improvement
May 10, 2017
Merged

mihaic merged 15 commits into
brainiak:masterfrom
mjanderson09:searchlight_improvement

Conversation

@mjanderson09

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread brainiak/searchlight/searchlight.py Outdated
larger portions of the volume called blocks.
"""
def __init__(self, sl_rad=1, max_blk_edge=10):
def __init__(self, sl_rad=1, max_blk_edge=-1, shape=Cube):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document the shape parameter. I suggest you add an empty superclass from which both Cube and Diamond inherit, which you can use to document the type of the parameter.

Comment thread brainiak/searchlight/searchlight.py Outdated
class Diamond:
"""Diamond

Searchlight shape which is a (2*rad+1)^3 diamond

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean the diamond contains exactly that number of voxels?

Comment thread brainiak/searchlight/searchlight.py Outdated
"""
self.sl_rad = sl_rad
self.max_blk_edge = max_blk_edge
if max_blk_edge == -1:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not let the user specify max_blk_edge=sl_rad*3 as parameter?

Comment thread tests/searchlight/test_shapes.py Outdated
@@ -0,0 +1,80 @@
# Copyright 2016 Intel Corporation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think theses tests should be part of "test_searchlight.py".

Comment thread tests/searchlight/test_shapes.py Outdated
from brainiak.searchlight.searchlight import Searchlight
from brainiak.searchlight.searchlight import Diamond

def test_cube():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests should be called test_searchlight_with_cube/diamond, because they test the shapes' usage in the searchlight, not the shape classes themselves.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not addressed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I've made this change. Thank you.

Comment thread brainiak/searchlight/searchlight.py Outdated
searchlight cube, not counting the center voxel

"""
super(Cube, self).__init__(rad)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should call super() with no arguments (also in Diamond):
https://docs.python.org/3/library/functions.html#super

Comment thread brainiak/searchlight/searchlight.py Outdated
"""
super(Cube, self).__init__(rad)
self.rad = rad
self.data = np.ones((2*rad+1, 2*rad+1, 2*rad+1), dtype=np.bool)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please document data as a class attribute in the superclass?

@mihaic

mihaic commented May 1, 2017

Copy link
Copy Markdown
Member

@yidawang, it looks like the size of the output array has changed for 26 to 23 in "test_mvpa_voxel_selection". Any idea why?

@mihaic mihaic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could make the following changes, it would help with clarity.

Comment thread brainiak/searchlight/searchlight.py Outdated
mysl_rad:-mysl_rad,
mysl_rad:-mysl_rad]

def check_mask(mask_cube):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this a method and document it.

Comment thread brainiak/searchlight/searchlight.py Outdated
----------

data_ : a 3D boolean numpy array of size (2*rad+1)^3 which is set
to True within the boundaries of the desired shape

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, this is a mask, so it should be named appropriately, e.g., mask_.

Comment thread brainiak/searchlight/searchlight.py Outdated
----------

data_ : a 3D boolean numpy array of size (2*rad+1)^3 which is set
to True within the boundaries of the desired shape

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change the array description to use shape, like elsewhere in BrainIAK, e.g., of shape (2*rad+1, 2*rad+1, 2*rad+1)?

Comment thread brainiak/searchlight/searchlight.py Outdated

def check_mask(mask_cube):
res = mask_cube[self.shape]
return np.any(res) and np.all(res)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't np.all sufficient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because it returns true for an empty array.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then how about:

return len(res) > 0 and np.all(res)

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

Successfully merging this pull request may close these issues.

2 participants