Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparent support for indexing neuronlists with numeric ids #390

Open
jefferis opened this issue Jun 5, 2019 · 1 comment
Open

Transparent support for indexing neuronlists with numeric ids #390

jefferis opened this issue Jun 5, 2019 · 1 comment
Assignees

Comments

@jefferis
Copy link
Collaborator

jefferis commented Jun 5, 2019

At the moment if a numeric id e.g. that used as the unique identified for a neuron in a database is used to index a neuronlist, it will be interpreted as an int. This is not what one wants. The current workaround is to convert such ids to character vectors before the indexing call, but this must be done explicitly. Perhaps we could make a simple class e.g. nlid that would indicate that the contents (which could be any class including R primitives) should be used for indexing by equality not by position.

tenthousandneurons=read.neurons("bigfolder")
# ouch
tenthousandneurons[12134567] 
# ok
tenthousandneurons[as.character("12134567")]
#  a (little bit) better
tenthousandneurons[nlid(12134567)]

# likewise
plot3d(tenthousandneurons, nlid(12134567))

# could work with `plot3d.nlid` method (which could just pass through to `plot3d.character`)
plot3d(nlid(12134567))

# But more useful would be e.g.
x=read.neurons.catmaid(nlid(...))
selids=find.neurons(x)
plot3d(x, selids)
@jefferis jefferis self-assigned this Jun 5, 2019
@jefferis
Copy link
Collaborator Author

jefferis commented Jun 5, 2019

Would need to check any existing locations where subsets are processed because sometimes existing logic might get in the way e.g.

https://github.com/jefferis/nat/blob/5ef3314ea2cc8edd685754b921b0dc6193b8ba69/R/neuronlist.R#L432-L446

where it is assumed that if our subset is not a character then we should be using it to subset literally the names of the neuronlist. We would instead need to have special case logic for nlid or be more restrictive in which types we continue to convert into names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant