Skip to content

Commit

Permalink
FIX: check minor docstring issues in some internal functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dfsp-spirit committed Feb 2, 2024
1 parent 6cf9572 commit 5f8c2cf
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 33 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
freesurferformats Changes
=========================

Version 0.1.18
-------------------------
- Fix four minor docstring issues in internal functions. An email by the CRAN team required this.


Version 0.1.17
-------------------------
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: freesurferformats
Type: Package
Title: Read and Write 'FreeSurfer' Neuroimaging File Formats
Version: 0.1.17.9000
Version: 0.1.18
Authors@R: person("Tim", "Schäfer", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0002-3683-8070"))
Maintainer: Tim Schäfer <[email protected]>
Description: Provides functions to read and write neuroimaging data in various file formats, with a focus on 'FreeSurfer' <http://freesurfer.net/> formats. This includes, but is not limited to, the following file formats: 1) MGH/MGZ format files, which can contain multi-dimensional images or other data. Typically they contain time-series of three-dimensional brain scans acquired by magnetic resonance imaging (MRI). They can also contain vertex-wise measures of surface morphometry data. The MGH format is named after the Massachusetts General Hospital, and the MGZ format is a compressed version of the same format. 2) 'FreeSurfer' morphometry data files in binary 'curv' format. These contain vertex-wise surface measures, i.e., one scalar value for each vertex of a brain surface mesh. These are typically values like the cortical thickness or brain surface area at each vertex. 3) Annotation file format. This contains a brain surface parcellation derived from a cortical atlas. 4) Surface file format. Contains a brain surface mesh, given by a list of vertices and a list of faces.
Expand All @@ -16,6 +16,7 @@ Imports:
Suggests:
knitr,
rmarkdown,
curl,
testthat (>= 2.1.0),
oro.nifti (>= 0.9),
gifti (>= 0.7.5),
Expand Down
4 changes: 2 additions & 2 deletions R/read_fs_curv.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ read.fs.morph.txt <- function(filepath) {
#'
#' @description Read a 3-byte integer from a binary file handle. Advances the pointer accordingly.
#'
#' @param filehandle: file handle
#' @param filehandle file handle
#'
#' @return integer: The read integer.
#' @return integer, The read integer.
#'
#'
#' @keywords internal
Expand Down
6 changes: 3 additions & 3 deletions R/read_fs_surface.R
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ parse.stl.ascii.face <- function(stl_face_lines) {
#'
#' @description Some mesh file formats like STL do not store the faces as indices into a vertex list ('indexed mesh'), but repeat all vertex coordinates for each face ('polygon soup'). This function creates an indexed mesh from a polysoup.
#'
#' @param face_vertex_coords numerical matrix with *n* rows and 3 columns, the vertex coordinates of the faces. Each row contains the x,y,z coordinates of a single vertex, and three consecutive vertex rows form a triangular face.
#' @param faces_vertex_coords numerical matrix with *n* rows and 3 columns, the vertex coordinates of the faces. Each row contains the x,y,z coordinates of a single vertex, and three consecutive vertex rows form a triangular face.
#'
#' @param digits the precision (number of digits after decimal separator) to use when to determine whether two x,y,z coords define the same vertex.
#'
Expand Down Expand Up @@ -1465,11 +1465,11 @@ int.to.col.brainvoyager <- function(int_val) {

#' @title Stop unless surf is an fs.surface
#'
#' @param surf fs.surface instance or anything else
#' @param surface fs.surface instance or anything else
#'
#' @param param_name character string, used in stop message to identify the parameter.
#'
#' @return Called for the side effect of stopping if surf is not an fs.surface instance.
#' @return Called for the side effect of stopping if surface is not an fs.surface instance.
#'
#' @keywords internal
assert.surface <- function(surface, param_name="surface") {
Expand Down
4 changes: 2 additions & 2 deletions R/write_fs_curv.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ write.fs.morph.txt <- function(filepath, data) {
#'
#' @description Write a 3-byte integer to a binary file handle.
#'
#' @param filehandle: file handle (connection)
#' @param filehandle file handle (connection)
#'
#' @param data: number to write
#' @param data number to write
#'
#'
#' @keywords internal
Expand Down
28 changes: 14 additions & 14 deletions R/write_fs_mgh.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ mri_dtype_numbytes <- function(mri_dtype_code) {
#'
#' @description This function provides an educated guess on whether the given dtype is suitable for the data. It is usually called for the site effect of printing warnings in case something seems off.
#'
#' @param data the data to check, a vector, matrix or array typically
#' @param mridata the data to check, a vector, matrix or array typically
#'
#' @param mri_dtype_code integer, the MRI data type code. See \code{\link[freesurferformats]{translate.mri.dtype}}.
#'
Expand All @@ -204,51 +204,51 @@ mri_dtype_numbytes <- function(mri_dtype_code) {
#' @return logical, whether the dtype could be suitable. This is only a guess, as the checks are in no way complete.
#'
#' @keywords internal
check.dtype.for.data <- function(data, mri_dtype_code) {
check.dtype.for.data <- function(mridata, mri_dtype_code) {
could_be_okay = TRUE;
mri_dtype_name = translate.mri.dtype(mri_dtype_code);

if(mri_dtype_name == "MRI_UCHAR") {
dtype_min_value = 0L;
dtype_max_value = 255L;
if(is.integer(data)) {
if(min(data) < dtype_min_value | max(data) > dtype_max_value) {
warning(sprintf("Data type '%s' cannot store data outside of range [%d, %d], but your data has range [%d, %d]. Output will be wrong, check datatype.\n", mri_dtype_name, dtype_min_value, dtype_max_value, min(data), max(data)));
if(is.integer(mridata)) {
if(min(mridata) < dtype_min_value | max(mridata) > dtype_max_value) {
warning(sprintf("Data type '%s' cannot store mridata outside of range [%d, %d], but your mridata has range [%d, %d]. Output will be wrong, check datatype.\n", mri_dtype_name, dtype_min_value, dtype_max_value, min(mridata), max(mridata)));
could_be_okay = FALSE;
}

} else {
warning(sprintf("Data type '%s' requires 'integer' data, found type '%s'.\n", mri_dtype_name, typeof(data)));
warning(sprintf("Data type '%s' requires 'integer' mridata, found type '%s'.\n", mri_dtype_name, typeof(mridata)));
could_be_okay = FALSE;
}
}

if(mri_dtype_name == "MRI_SHORT") {
dtype_min_value = 0L;
dtype_max_value = 65535L;
if(is.integer(data)) {
if(min(data) < dtype_min_value | max(data) > dtype_max_value) {
warning(sprintf("Data type '%s' cannot store data outside of range [%d, %d], but your data has range [%d, %d]. Output will be wrong, check datatype.\n", mri_dtype_name, dtype_min_value, dtype_max_value, min(data), max(data)));
if(is.integer(mridata)) {
if(min(mridata) < dtype_min_value | max(mridata) > dtype_max_value) {
warning(sprintf("Data type '%s' cannot store mridata outside of range [%d, %d], but your mridata has range [%d, %d]. Output will be wrong, check datatype.\n", mri_dtype_name, dtype_min_value, dtype_max_value, min(mridata), max(mridata)));
could_be_okay = FALSE;
}

} else {
warning(sprintf("Data type '%s' requires 'integer' data, found type '%s'.\n", mri_dtype_name, typeof(data)));
warning(sprintf("Data type '%s' requires 'integer' mridata, found type '%s'.\n", mri_dtype_name, typeof(mridata)));
could_be_okay = FALSE;
}
}


if(mri_dtype_name == "MRI_INT") {
if(!is.integer(data)) {
warning(sprintf("Data type '%s' requires 'integer' data, found type '%s'.\n", mri_dtype_name, typeof(data)));
if(!is.integer(mridata)) {
warning(sprintf("Data type '%s' requires 'integer' mridata, found type '%s'.\n", mri_dtype_name, typeof(mridata)));
could_be_okay = FALSE;
}
}

if(mri_dtype_name == "MRI_FLOAT") {
if(!is.double(data)) {
warning(sprintf("Data type '%s' requires 'double' data, found type '%s'.\n", mri_dtype_name, typeof(data)));
if(!is.double(mridata)) {
warning(sprintf("Data type '%s' requires 'double' mridata, found type '%s'.\n", mri_dtype_name, typeof(mridata)));
could_be_okay = FALSE;
}
}
Expand Down
6 changes: 3 additions & 3 deletions man/assert.surface.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/check.dtype.for.data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/fread3.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/fwrite3.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/polygon.soup.to.indexed.mesh.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified web/examples/annot_unique_across_hemis.R
100755 → 100644
Empty file.
Empty file modified web/examples/convert_pervertexdata_file.R
100755 → 100644
Empty file.

0 comments on commit 5f8c2cf

Please sign in to comment.