write.neuron: Write out a neuron in any of the file formats we know about

View source: R/neuron-io.R

write.neuronR Documentation

Write out a neuron in any of the file formats we know about

Description

If file is not specified the neuron's InputFileName field will be checked (for a dotprops object it will be the 'file' attribute). If this is missing there will be an error. If dir is specified it will be combined with basename(file). If file is specified but format is not, it will be inferred from file's extension.

Usage

write.neuron(
  n,
  file = NULL,
  dir = NULL,
  format = NULL,
  ext = NULL,
  Force = FALSE,
  MakeDir = TRUE,
  ...
)

Arguments

n

A neuron

file

Path to output file

dir

Path to directory (this will replace dirname(file) if specified)

format

Unique abbreviation of one of the registered file formats for neurons including 'swc', 'hxlineset', 'hxskel'

ext

Will replace the default extension for the filetype and should include the period eg ext='.amiramesh' or ext='_reg.swc'. The special value of ext=NA will prevent the extension from being changed or added e.g. if the desired file name does not have an extension.

Force

Whether to overwrite an existing file

MakeDir

Whether to create directory implied by file argument.

...

Additional arguments passed to selected writer function

Details

Note that if file does not have an extension then the default extension for the specified format will be appended. This behaviour can be suppressed by setting ext=NA.

Value

return value

See Also

write.neuron, fileformats, saveRDS

Examples

# show the currently registered file formats that we can write
fileformats(class='neuron', write=TRUE)
## Not run: 
write.neuron(Cell07PNs[[1]], file='myneuron.swc')
# writes out "myneuron.swc" in SWC format
write.neuron(Cell07PNs[[1]], format = 'hxlineset', file='myneuron.amiramesh')
# writes out "myneuron.amiramesh" in Amira hxlineset format
write.neuron(Cell07PNs[[1]], format = 'hxlineset', file='myneuron')
# writes out "myneuron.am" in Amira hxlineset format

## End(Not run)

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