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.

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

Arguments

n A neuron Path to output file Path to directory (this will replace dirname(file) if specified) Unique abbreviation of one of the registered file formats for neurons including 'swc', 'hxlineset', 'hxskel', if no format can be extracted from the filename and the ext parameter, then it defaults to 'swc' Will replace the default extension for the filetype and should include the period e.g. 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. Whether to overwrite an existing file Whether to create directory implied by file argument. Additional arguments passed to selected writer function

return value

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.

If you find that some software rejects your SWC files, try setting normalise.ids=TRUE (see examples). This will ensure that the vertex ids are sequentially ascending integers (1:N). The default value of normalise.ids=NA will normalise PointNo vertex ids only when a vertex is connected (by the Parent field) to a vertex that had not yet been defined. Many readers make the assumption that this is true. When normalise.ids=F the vertex ids will not be touched.

write.neurons, read.neuron, fileformats, saveRDS

Examples

# show the currently registered file formats that we can write
fileformats(class='neuron', write=TRUE)#> [1] "hxlineset" "hxskel"    "rds"       "swc"       "vtk"      if (FALSE) {
# write out "myneuron.swc" in SWC format
write.neuron(Cell07PNs[[1]], file='myneuron.swc')
# write out "myneuron.swc" in SWC format, normalising the integer ids that
# label every node (this is required by some SWC readers e.g. Fiji)
write.neuron(Cell07PNs[[1]], file='myneuron.swc', normalise.ids=TRUE)

# write out "myneuron.amiramesh" in Amira hxlineset format
write.neuron(Cell07PNs[[1]], format = 'hxlineset', file='myneuron.amiramesh')

# write out "myneuron.am" in Amira hxlineset format
write.neuron(Cell07PNs[[1]], format = 'hxlineset', file='myneuron')
}