[pymvpa] Extracting a part of dataset for a re-selection of voxels in the already selected features
akama.h.aa
akama.h.aa at m.titech.ac.jp
Tue Mar 25 01:58:06 UTC 2014
Dear PyMVPA people
I'd like to extract from a Dataset only a corresponding part of some newly re-selected voxels which should be a subset of (already) selected features.
Is the following one I've made is good? Or did you already implemented a similar one in the package? (I am not so self-confident)
def getNewEventDatasetWithOnlyReselectedVoxels(OriginalEventDataset,ReslectedVoxelsIndices):
voxelIndicesOfOriginalEventDataset=OriginalEventDataset.fa.voxel_indices
list_voxelIndicesOfOriginalEventDataset=[[0,0,0]]*len(voxelIndicesOfOriginalEventDataset)#Initialization
for i in range(len(list_voxelIndicesOfOriginalEventDataset)):
list_voxelIndicesOfOriginalEventDataset[i]=list(voxelIndicesOfOriginalEventDataset[i])
ReslectedVoxelsIndices_pos=[0]*len(ReslectedVoxelsIndices)
for j in range(len(ReslectedVoxelsIndices)):
if list(ReslectedVoxelsIndices[j]) not in list_voxelIndicesOfOriginalEventDataset:
print str(list(ReslectedVoxelsIndices[j])) + 'not included'
else:
found_pos=list_voxelIndicesOfOriginalEventDataset.index(list(ReslectedVoxelsIndices[j]))
#index() can be used only for a list, not used for numpy.ndarray
ReslectedVoxelsIndices_pos[j]=found_pos
while (True):
try:
ReslectedVoxelsIndices_pos.remove(0)
except:
break
newselEventDataset=OriginalEventDataset[:,ReslectedVoxelsIndices_pos]
return newselEventDataset
Best regards
Hiroyuki AKAMA
Associate Professor, Graduate School of Decision Science and Technology
Tokyo Institute of Technology,
W9-10, O-okayama, Meguro-ku, Tokyo-152-8552
Japan
More information about the Pkg-ExpPsy-PyMVPA
mailing list