Skip to content

YuhangTom/wire

Repository files navigation

wire wire website

Lifecycle: experimental Last-changedate CRAN status Codecov test coverage R-CMD-check

The goal of wire is to provide a systematic reproducible automatic algorithm to analyze the similarity between wire cut scans.

Installation

You can install the development version of wire from GitHub with:

# install.packages("devtools")
devtools::install_github("YuhangTom/wire")

Usage

Data

The original scans for the wire cuts are stored in x3p format of width around 2300 and height around 1800, under a resolution $0.645 \mu m \times 0.645 \mu m$, with each file being at least 15 MB, which is much larger compared to the file limit of 5 MB for a R package. Therefore, we subsampled the original scans by a factor of 10, and saved them as x3p_subsamples in the package. The data can be used by:

library(wire)

x3p_subsamples
#> $`T1AW-LI-R1`
#> x3p object
#> size (width x height): 239 x 172 in pixel 
#> resolution: 6.4500e+00 x 6.4500e+00 
#> 
#> $`T1AW-LI-R2`
#> x3p object
#> size (width x height): 238 x 171 in pixel 
#> resolution: 6.4500e+00 x 6.4500e+00

Inner polygon

To remove the edge effect, we extract the inner part of the scan, which can be achieved by:

x3p <- x3p_subsamples[[1]]
insidepoly_df <- x3p_insidepoly_df(x3p, mask_col = "#FF0000", concavity = 1.5, b = 1, ifplot = TRUE)

attr(insidepoly_df, "x3p_plot")

attr(insidepoly_df, "number_of_missing_immediate_neighbors_plot")

attr(insidepoly_df, "standard_deviation_of_non_missing_immediate_neighbors_plot")

attr(insidepoly_df, "number_of_missing_immediate_neighbors_boxplot")

Remove trend

To remove the overall trend on the inner surface, we can use:

x3p_inner_nomiss_res <- df_rmtrend_x3p(insidepoly_df)
x3p_inner_nomiss_res
#> x3p object
#> size (width x height): 239 x 172 in pixel 
#> resolution: 6.4500e+00 x 6.4500e+00

Imputation

We can impute the missing values inside the surface by:

x3p_inner_impute <- x3p_impute(x3p_inner_nomiss_res, ifout = TRUE, ifsave = FALSE, dir_name = NULL, ifplot = TRUE)
attr(x3p_inner_impute, "x3p_impute_0_plot")

attr(x3p_inner_impute, "x3p_impute_1_plot")

attr(x3p_inner_impute, "x3p_impute_n_plot")

Rotation

We can rotate the surface to the correct angle by:

x3p_bin_rotate <- x3p_vertical(x3p_inner_impute, min_score_cut = 5, ifplot = TRUE)

attr(x3p_bin_rotate, "nfline_red_plot")

attr(x3p_bin_rotate, "MLE_loess_red_plot")

attr(x3p_bin_rotate, "nfline_blue_plot")

attr(x3p_bin_rotate, "MLE_loess_blue_plot")

Signal extraction

To extract signals from the rotated surface, two methods are provided, implemented by wire::x3p_raw_sig_df and wire::x3p_shift_sig_df, respectively:

raw_sig_df <- x3p_raw_sig_df(x3p_bin_rotate, ifplot = TRUE)
attr(raw_sig_df, "sig_df_plot")

shift_sig_df <- x3p_shift_sig_df(x3p_bin_rotate, ifplot = TRUE)
attr(shift_sig_df, "x3p_before_shift_plot")

attr(shift_sig_df, "x3p_after_shift_plot")

attr(shift_sig_df, "fn_align_plot")
#> NULL
attr(shift_sig_df, "MSE_plot")

attr(shift_sig_df, "sig_df_plot")

The signals and hooks can be further smoothed and removed by:

raw_ccsig_df <- df_ccsig(raw_sig_df, ifplot = TRUE)
attr(raw_ccsig_df, "sig_df_plot")

Signal alignment

Extracted signals can be aligned, and the cross-correlation can be computed:

aligned <- vec_align_sigs_list(raw_sig_df$sig, shift_sig_df$sig, ifplot = TRUE)
attr(aligned, "sig_align_plot")

About

R package wire

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages