npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ccig/dicom-anonymizer

v0.2.3

Published

Anonymize dicom P10 files with customizable scripts

Downloads

15

Readme

DICOM Anonymizer

The DICOM Anonymizer is a tool designed to remove personal patient information details and non-relevant data from medical image DICOM P10 files. It utilizes a deterministic and non-reversible hashing algorithm to modify UIDs, patient ID, and names. The hashing algorithm ensures high collision resistance, producing the same values for the same input, which avoids duplication of images and inconsistent referenced sequences.

Features

  • Anonymizes DICOM P10 files by removing personal patient information and non-relevant data.
  • Utilizes a deterministic and non-reversible hashing algorithm for modifying UIDs, patient ID, and names.
  • High collision resistance ensures consistency and avoids duplication of images and inconsistent referenced sequences.
  • Along with the annymization files, an array can be provided to the "anonymizeFile" function which will be filled with a map referencing the old and new ID's so that the user can trace where the anonymized files came from. If not needed just omit the second argument in the "anonymizeFile" function

Installation

You can install the DICOM Anonymizer via npm:

npm install @ccig/dicom-anonymizer

or clone the project from github

git clone https://github.com/CCIG-Champalimaud/dicom-anonymizer.git

and build a distribution bundle with

npm run build

or

yarn build

Usage

Node.js

To use the DICOM Anonymizer, you need to create an instance of the DicomAnonymizer class by passing a configuration object:

const { DicomAnonymizer } = require('dicom-anonymizer');

const config = {
  dicomImplementationClassUID: 'YOUR_IMPLEMENTATION_CLASS_UID',
  dicomImplementationVersionName: 'YOUR_IMPLEMENTATION_VERSION_NAME',
  dicomUIDPrefix: 'YOUR_UID_PREFIX',
  configuration: {
    // Additional configuration options and scripting rules for the anonymization process
    // check src/protocols for blacklist and whitelist aproach and modify it according to needs
  }
    
};

const anonymizer = new DicomAnonymizer(config);
// Check if a file is a DICOM P10 file
const isDicomP10 = await anonymizer.checkIfFileIsDicomP10('path/to/dicom/file.dcm');

// Get the DICOM dataset from a file
const dataset = await anonymizer.getDatasetFromFile('path/to/dicom/file.dcm');

// Preview the anonymization changes as a datatable
const previewTable = await anonymizer.previewAnonymizeFileAsDatatable('path/to/dicom/file.dcm');

// Anonymize the DICOM file
const blob = await anonymizer.anonymizeFile('path/to/dicom/file.dcm'); //optionally pass an array reference as 2nd argument to keep track of the old -> new ID's for each Series

//blob can then be saved somewhere with fs for example
const buffer = Buffer.from( await blob.arrayBuffer() );
fs.writeFileSync('anonymized.dcm', buffer);
}

Browser

after building the project, the dist/ folder will contain dicom-anonymizer.js bundle to include in you html just add it to the tag of your index.html and then use it later on a script like the following:

async function start(){
    //initialize instance of anonymizer
    const dicomAnonymizer = new DicomAnonymizer()
    
    //get the file added in input
    const selectedFile = document.getElementById("dicomFileInput").files[0];
    if(!selectedFile) {
        return console.warn('no file found')
    }
    //test if it is a dicom P10 or not
    const checkIsDicom = await dicomAnonymizer.checkIfFileIsDicomP10(selectedFile)
    if(!checkIsDicom) {
        return console.warn('not dicom file')
    }

    //read and parse dicom file
    const ds = await dicomAnonymizer.getDatasetFromFile(selectedFile)
    
    //load configuration (default is blacklist)
    dicomAnonymizer.setConfig('whitelist')

    //anonymize the file
    const map = []
    const blob = await dicomAnonymizer.anonymizeFile(selectedFile, map)
    console.log(map)
    downloadBlob(blob)
}




function downloadBlob(blob){
    const a = document.createElement("a")
    document.body.appendChild(a)
    a.style = "display: none"
    const url = window.URL.createObjectURL(blob)
    a.href = url
    a.download = "anonymized.dcm"
    a.click()
    window.URL.revokeObjectURL(url)
}

Contributing

Contributions are welcome! Please use GitHub issues and/or pull requests. We'll be happy to assist you!

License

This project is licensed under the MIT License