You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered a problem that the brainiak.searchlight always return the output have None at the edge of data. This is problematic because I did searchlight on native EPI images with minimal preprocessing. Some participants have bigger brain that cover the top and bottom edge of native EPI image. These None were produced at top and bottom edge of brain, but these voxels should have eligible searchlight results.
I'm not sure if this is a bug. And I have not seen any warning about this in the document. I would like to post the issue here, hoping this could be fixed, or could be added as a warning in the document to inform people who are going to use searchlight module.
Here is a minimal duplicable example to present the issue:
I first generate a toy data and specify mask as all ones (include all data in searchlight).
# import packageimportnumpyasnpfrombrainiak.searchlight.searchlightimportSearchlight# making a toy datadsize=10t=20data=np.zeros((dsize,dsize,dsize,t))
foriinrange(dsize//2):
data[i:(dsize-i), i:(dsize-i), i:(dsize-i), :] +=1mask=np.ones((dsize,dsize,dsize), dtype=int)
# print the toy dataprint(f"data shape: {data.shape}")
print(data[dsize//2, :, :, 0])
print(f"mask shape: {mask.shape}")
print(mask[dsize//2, :, :])
It seems that the searchlight did not run at the edge of the input data.
I try padding zero at the edge of data and run the searchlight again.
rad=3# specify searchlight radius# creating a zero matrix with expanded x, y, z axispaddata=np.zeros((dsize+rad*2, dsize+rad*2, dsize+rad*2, t))
# filling the original data at the centerpaddata[rad:(dsize+rad), rad:(dsize+rad), rad:(dsize+rad), :] =datapadmask=np.zeros((dsize+rad*2, dsize+rad*2, dsize+rad*2))
padmask[rad:(dsize+rad), rad:(dsize+rad), rad:(dsize+rad)] =maskprint(f"padding 0 data shape: {paddata.shape}")
print(paddata[(dsize+rad*2)//2, :, :, 0])
print(f"padding 0 mask shape: {padmask.shape}")
print(padmask[(dsize+rad*2)//2, :, :])
# run the searchlight again with padding datasl=Searchlight(sl_rad=rad, max_blk_edge=10)
sl.distribute([paddata], padmask)
sl.broadcast(0)
sl_results=sl.run_searchlight(sl_func, pool_size=1)
print(f"output shape: {sl_results.shape}")
print(sl_results[(dsize+rad*2)//2, :, :])
Hello, @yushiangsu. Thank you for thoroughly documenting the issues. This is indeed the intended behavior: the outer sl_rad voxels are considered padding. We could change the implementation to add and remove the padding automatically, but that would be a backward-incompatible change. Instead, I think we should document the current behavior.
I encountered a problem that the
brainiak.searchlight
always return the output haveNone
at the edge of data. This is problematic because I did searchlight on native EPI images with minimal preprocessing. Some participants have bigger brain that cover the top and bottom edge of native EPI image. TheseNone
were produced at top and bottom edge of brain, but these voxels should have eligible searchlight results.I'm not sure if this is a bug. And I have not seen any warning about this in the document. I would like to post the issue here, hoping this could be fixed, or could be added as a warning in the document to inform people who are going to use searchlight module.
Here is a minimal duplicable example to present the issue:
I first generate a toy data and specify mask as all ones (include all data in searchlight).
Creating the simplest function that apply on each searchlight
Implementing searchlight with radius = 3 and print the output
I tried with another radius = 2 and print the output
It seems that the searchlight did not run at the edge of the input data.
I try padding zero at the edge of data and run the searchlight again.
Then I could trim down the padding value and got more plausible results.
The text was updated successfully, but these errors were encountered: