write.neurons: Write neurons from a neuronlist object to individual files,...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/neuron-io.R

Description

Write neurons from a neuronlist object to individual files, or a zip archive

Usage

1
2
write.neurons(nl, dir, format = NULL, subdir = NULL, INDICES = names(nl),
  files = NULL, Force = FALSE, ...)

Arguments

nl

neuronlist object

dir

directory to write neurons, or path to zip archive (see Details).

format

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

subdir

String naming field in neuron that specifies a subdirectory OR expression to evaluate in the context of neuronlist's df attribute

INDICES

Character vector of the names of a subset of neurons in neuronlist to write.

files

Character vector or expression specifying output filenames. See examples and write.neuron for details.

Force

Whether to overwrite an existing file

...

Additional arguments passed to write.neuron

Details

See write.neuron for details of how to specify the file format/extension/name of the output files and how to establish what output file formats are available. A zip archive of files can be written by specifying a value of dir that ends in .zip.

Value

the path to the output file(s), absolute when this is a zip file.

Author(s)

jefferis

See Also

write.neuron, read.neurons, fileformats

Other neuronlist: *.neuronlist, is.neuronlist, neuronlist-dataframe-methods, neuronlistfh, neuronlist, nlapply, read.neurons

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 
# write some neurons in swc format
write.neurons(Cell07PNs, dir="testwn", format='swc')
# write some neurons in swc format for picky software
write.neurons(Cell07PNs, dir="testwn", format='swc', normalise.ids=TRUE)

# write some neurons in Amira hxlineset format
write.neurons(Cell07PNs, dir="testwn", format='hxlineset')

# organise new files in directory hierarchy by glomerulus and Scored.By field
write.neurons(Cell07PNs,dir="testwn",
  subdir=file.path(Glomerulus,Scored.By),format='hxlineset')
# ensure that the neurons are named according to neuronlist names
write.neurons(Cell07PNs, dir="testwn", files=names(Cell07PNs),
  subdir=file.path(Glomerulus,Scored.By),format='hxlineset')
# only write a subset
write.neurons(subset(Cell07PNs, Scored.By="ACH"),dir="testwn2",
  subdir=Glomerulus,format='hxlineset')
# The same, but likely faster for big neuronlists
write.neurons(Cell07PNs, dir="testwn3",
  INDICES=subset(Cell07PNs,Scored.By="ACH",rval='names'),
  subdir=Glomerulus,format='hxlineset')
# set file name explicitly using a field in data.frame
write.neurons(subset(Cell07PNs, Scored.By="ACH"),dir="testwn4",
  subdir=Glomerulus, files=paste0(ID,'.am'), format='hxlineset')

## End(Not run)

jefferis/nat documentation built on Oct. 25, 2018, 6:29 p.m.