read.neuron: Read a single neuron from a file

View source: R/neuron-io.R

read.neuronR Documentation

Read a single neuron from a file

Description

Read a single neuron from a file

Usage

read.neuron(f, format = NULL, class = c("neuron", "ngraph"), ...)

Arguments

f

Path to file. This can be a URL, in which case the file is downloaded to a temporary location before reading.

format

The file format of the neuron. When format=NULL, the default, read.neuron will infer the file format from the extension or file header (aka magic) using the fileformats registry.

class

The class of the returned object - presently either "neuron" or "ngraph"

...

additional arguments passed to format-specific readers

Details

This function will handle neuron and dotprops objects saved in R .rds or .rda format by default. Additional file formats can be registered using fileformats.

At the moment the following formats are supported using file readers already included with the nat package:

  • swc See read.neuron.swc. SWC files can also return an ngraph object containing the neuron structure in a (permissive) general graph format that also contains the 3D positions for each vertex.

  • neuroml See read.neuron.neuroml

  • fijitraces See read.neuron.fiji. The file format used by the SNT plugin of Fiji/ImageJ.

  • hxlineset,hxskel Two distinct fileformats used by Amira. hxlineset is the generic one, hxskel is used by the hxskeletonize extension of Schmitt and Evers (see refs).

  • rda,rds Native R cross-platform binary formats (see load, readRDS). Note that RDS only contains a single unnamed neuron, whereas rda contains one or more named neurons.

References

Schmitt, S. and Evers, J. F. and Duch, C. and Scholz, M. and Obermayer, K. (2004). New methods for the computer-assisted 3-D reconstruction of neurons from confocal image stacks. Neuroimage 4, 1283–98. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.neuroimage.2004.06.047")}

See Also

write.neuron, read.neurons, fileformats

Examples

## Not run: 
# note that we override the default NeuronName field
n=read.neuron(system.file("tests/testthat/testdata","neuron","EBT7R.CNG.swc",package='nat'),
  NeuronName="EBT7R")
# use a function to set the NeuronName field
n3=read.neuron(system.file("tests/testthat/testdata","neuron","EBT7R.CNG.swc",package='nat'),
  NeuronName=function(x) sub("\\..*","",x))
# show the currently registered file formats that we can read
fileformats(class='neuron', read=TRUE)

## End(Not run)

nat documentation built on May 29, 2024, 10:36 a.m.