We can make Brain and Nifti objects indexable by making them iteratable objects: https://stackoverflow.com/questions/5359679/python-class-accessible-by-iterator-and-index
It looks like this involves adding __iter__ and __getitem__ methods:
__iter__ returns the next item in the sequence (i.e. start a counter at 0 when the objects is initialized, and each time __iter__ is called, return object[counter+1] if len(object) < counter, or None otherwise, and then increment counter
__getitem__ returns the given item(s)
We can make Brain and Nifti objects indexable by making them iteratable objects: https://stackoverflow.com/questions/5359679/python-class-accessible-by-iterator-and-index
It looks like this involves adding
__iter__and__getitem__methods:__iter__returns the next item in the sequence (i.e. start acounterat 0 when the objects is initialized, and each time__iter__is called, returnobject[counter+1]iflen(object) < counter, orNoneotherwise, and then incrementcounter__getitem__returns the given item(s)