A nushell plugin to parse Dicom objects.
This plugin is in the early stage of the development. It is usable but it might not be able to cope with all Dicom objects. One notable limitation is that all Dicom objects are expected to have a preamble.
I'm still trying to figure out what is the most useful way of using this plugin. Please feel free to try it out, send feedback in Discussions or report problems in Issues.
dcm
plugin reads its input from single values or from specific columns:
- dcm
: expects a string/filename or binary Dicom data
- dcm $column_name
: reads a string/filename or binary Dicom data from $column
. This is
equivalent to get $column | dcm
.
sh
echo file.dcm | dcm # uses filename/string to specify which file to open
open file.dcm | dcm # pass binary data to `dcm`
ls I4 | dcm name # use `name` column as the filename
echo file.dcm | wrap foo | dcm foo # use `foo` column as the filename
open I4 | wrap foo | dcm foo # use `foo` column as binary data
sh
open file.dcm | dcm | to json --pretty 2
open file.dcm | dcm | to yaml
sh
ls *.dcm | dcm name | to json --pretty 2
ls *.dcm | dcm name | to yaml
PixelSpacing is an array with 2 values. To flatten the array use .0
and .1
indices.
```sh
let files = (ls | where type == File)
echo $files | select name size | merge { echo $files | dcm name | select SOPInstanceUID Modality PixelSpacing.0 PixelSpacing.1 } | sort-by size ```
dcm name
is a shortcut for get name | dcm
. The following commands are equivalent:
```sh
echo $files | select name size | merge { echo $files | dcm name | select SOPInstanceUID Modality PixelSpacing.0 PixelSpacing.1 } | sort-by size
echo $files | select name size | merge { echo $files.name | dcm | select SOPInstanceUID Modality PixelSpacing.0 PixelSpacing.1 } | sort-by size
echo $files | select name size | merge { echo $files | get name | dcm | select SOPInstanceUID Modality PixelSpacing.0 PixelSpacing.1 } | sort-by size ```
Note that not all Dicom files have (0008,0060)
Modality tag available. This will default missing to ???
.
sh
find . -type f | lines | dcm | default Modality '???' | histogram Modality
Build and install the plugin to your PATH
using
sh
cargo install nu_plugin_dcm