Giter VIP home page Giter VIP logo

musephi's Introduction

musePHI

R-CMD-check

musePHI is a package designed to assist in the de-identification of MUSE ECG XML files. It enables users to replace sensitive patient information within XML files with placeholders, maintaining the overall structure of the files. This approach helps in ensuring patient privacy while allowing the data to be used for research or analysis purposes.

Disclaimer

It is the responsibility of the user to accurately identify and replace values that need to be de-identified from the XML file. Furthermore, users must validate the results to ensure no personal health information (PHI) is inadvertently disclosed. The developers of musePHI assume no liability for the misuse of this software or the inadvertent sharing of PHI.

Installation

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

# install.packages("devtools")
devtools::install_github("overdodactyl/musePHI")

Example

library(musePHI)

Define the elements you wish to replace in the MUSE XML file:

replace <- list(
  "PatientDemographics/PatientLastName" = "LastName",
  "PatientDemographics/PatientFirstName" = "FirstName",
  "PatientDemographics/PatientID" = "PatientID",
  "TestDemographics/AcquisitionDate" = "01-01-0001",
  "TestDemographics/AcquisitionTime" = "00:00:00"
)

For each element in the list, the name should be the path to an XML node (relative to RestingECG). The value is what the node will be replaced with.

Specify the path to your existing XML file and the path for the new de-identified XML file. Then, call muse_deidentify:

file <- muse_example("muse/muse_ecg1.xml")
output_file <- tempfile(fileext = ".xml")
muse_deidentify(file, output_file, replace)

NOTE: It’s recommended to save the de-identified ECG data to a new file to preserve the original data.

Parallelization

For users working with a large number of XML files, parallelization can significantly speed up the de-identification process. We recommend using the furrr package to efficiently parallelize your workload.

To demonstrate this, we will process 10000 XML files sequentially and in parallel using 10 CPUs.

First, create 10000 XML files in a temporary directory:

dir <- fs::path_temp("xmls")
fs::dir_create(dir)

for (i in 1:10000) {
  fs::file_copy(
    "inst/extdata/muse/muse_ecg1.xml",
    fs::file_temp(tmp_dir = dir, ext = ".xml")
  )
}

Next, create a list of XML files and create their new file paths:

xml_files <- fs::dir_ls(dir)
deidentified_dir <- fs::path_temp("deidentified_xmls")
fs::dir_create(deidentified_dir)
deidentified_xmls <- fs::path(deidentified_dir, fs::path_file(xml_files))
library(tictoc)

Run muse_deidentify sequentially:

tic()
for (i in seq_along(xml_files)) {
  muse_deidentify(xml_files[i], deidentified_xmls[i], replace)
}
toc()
#> 21.538 sec elapsed

Run in parallel:

library(furrr)
#> Loading required package: future
plan(multisession, workers = 10)
tic()
future_walk2(xml_files, deidentified_xmls, muse_deidentify, replace = replace)
toc()
#> 6.608 sec elapsed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.