| 1 | package PDL::IO::Dcm::Plugins::MRISiemens; | ||||||||||||||||||||||||||||
| 2 | #use base 'PDL::IO::Dcm'; | ||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use PDL; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use PDL::NiceSlice; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use List::Util qw/first /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Storable qw/dclone/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | our @ISA=qw/Exporter/; | |||||||||||||||||||||||||||
| 13 | 2 | our @EXPORT_OK=qw/init_dims populate_header setup_dcm/; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | my @key_list=("Echo Time","Echo Number","Echo Number(s)", 'Pixel Bandwidth', | |||||||||||||||||||||||||||
| 16 | "Instance Number",,'Window Center','Content Time', | ||||||||||||||||||||||||||||
| 17 | 'Nominal Interval','Instance Creation Time','Largest Image Pixel Value', | ||||||||||||||||||||||||||||
| 18 | 'Trigger Time','Window Width','Acquisition Time','Smallest Image Pixel Value', | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | 2 | my @key_list_csa=(); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub setup_dcm { | ||||||||||||||||||||||||||
|
Subroutine
setup_dcm: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 0 | my $opt=shift; | |||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $plugin = shift || 'MRISiemens'; # defaults to itself but can be set by caller, e.g. MRSSiemens. | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'MRISiemens'
MC/DC0%0/1
shift() || 'MRISiemens'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | $opt={} unless (ref($opt) eq 'HASH'); # ensure hash context | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | $$opt{$plugin}={} unless (ref ($$opt{$$opt{plugin}}) eq 'HASH'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | # split on series number by default | ||||||||||||||||||||||||||||
| 28 | 0 | $$opt{$plugin}->{id}=\&PDL::IO::Dcm::sort_series; | |||||||||||||||||||||||||||
| 29 | 0 | $$opt{$plugin}->{parser}=\&populate_header; | |||||||||||||||||||||||||||
| 30 | 0 | $$opt{$plugin}->{duplicates}=\&handle_duplicates; | |||||||||||||||||||||||||||
| 31 | 0 | $$opt{$plugin}->{key_list}=\@key_list; | |||||||||||||||||||||||||||
| 32 | 0 | $$opt{delete_raw}=1; # deletes the raw_dicom structure after parsing | |||||||||||||||||||||||||||
| 33 | 0 | push @PDL::IO::Dcm::key_list,'0051,100f'; | |||||||||||||||||||||||||||
| 34 | #say join ' ',%{$opt}; | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ($$opt{c_phase_t} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if ($$opt{c_phase_set} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | $$opt{$plugin}->{Dimensions}=[qw/x y z=partitions*slices T*Set*Phases Echo Channel/]; | |||||||||||||||||||||||||||
| 38 | } else { | ||||||||||||||||||||||||||||
| 39 | 0 | $$opt{$plugin}->{Dimensions}=[qw/x y z=partitions*slices T*Phases Echo Channel Set/]; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | }else { | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ($$opt{c_phase_set} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | $$opt{$plugin}->{Dimensions}=[qw/x y z=partitions*slices T Echo Channel Set*Phase/]; | |||||||||||||||||||||||||||
| 44 | } else { | ||||||||||||||||||||||||||||
| 45 | 0 | $$opt{$plugin}->{Dimensions}=[qw/x y z=partitions*slices T Echo Channel Phase Set /]; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | # part,sl,t,echo,coil,phase,set | ||||||||||||||||||||||||||||
| 49 | 0 | $$opt{$plugin}->{dim_order}=byte[6,10,4,1,0,2,3]; | |||||||||||||||||||||||||||
| 50 | $$opt{$plugin}->{internal_dims}=[ | ||||||||||||||||||||||||||||
| 51 | 0 | qw/x y coil echo cphase set t ? partition? chron_slice? ? slice ? some_id/]; | |||||||||||||||||||||||||||
| 52 | # note the order since dims change by clump! | ||||||||||||||||||||||||||||
| 53 | # partitions and slices | ||||||||||||||||||||||||||||
| 54 | 0 | $$opt{$plugin}->{clump_dims}=[[0,1],]; | |||||||||||||||||||||||||||
| 55 | # phases and set, phases*set and t | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | push (@{$$opt{$plugin}->{clump_dims}},[4,5]) if $$opt{c_phase_set}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | push (@{$$opt{$plugin}->{clump_dims}},[1,4]) if $$opt{c_phase_t}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | $$opt{$plugin}->{create_data} = \&create_data; | |||||||||||||||||||||||||||
| 59 | 0 | $$opt{$plugin}->{fill_data} = \&fill_data; | |||||||||||||||||||||||||||
| 60 | 0 | $$opt{$plugin}->{image_parser} = \&parser; | |||||||||||||||||||||||||||
| 61 | 0 | $$opt{$plugin}->{init_dims} = \&init_dims; | |||||||||||||||||||||||||||
| 62 | 0 | $$opt{$plugin}->{read_dcm} = \&read_dcm; | |||||||||||||||||||||||||||
| 63 | 0 | $opt; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub read_csa { | ||||||||||||||||||||||||||
|
Subroutine
read_csa: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||
| 67 | 0 | my $str=shift; # unprocessed native dicom string | |||||||||||||||||||||||||||
| 68 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 69 | 0 | my $csa=$self->hdr->{csa}; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | die "This is not a dicom CSA field\n" unless ($str =~m /^(OB|XX):SV10/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$str =~ /^(OB|XX):SV10/ and join("", unpack("c4LL", substr($str, 7, 20))) =~ /4321.*77/
MC/DC0%0/2
$str =~ /^(OB|XX):SV10/ and join("", unpack("c4LL", substr($str, 7, 20))) =~ /4321.*77/
$str =~ /^(OB|XX):SV10/
join("", unpack("c4LL", substr($str, 7, 20))) =~ /4321.*77/
Truth table0%0/3
A and B
A= $str =~ /^(OB|XX):SV10/B= join("", unpack("c4LL", substr($str, 7, 20))) =~ /4321.*77/
| |||||||||||||||||||||||||||||
| 71 | and ((join '',unpack('c4LL',substr($str,7,20))) =~ m/4321.*77/)); | ||||||||||||||||||||||||||||
| 72 | 0 | my ($fields,$check)=unpack('LL',substr($str,11,8)); | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | die "This is not a dicom field (77)\n" unless $check == 77; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | my (@names,@values); | |||||||||||||||||||||||||||
| 75 | 0 | my $str=substr($str,19,); # trim the header | |||||||||||||||||||||||||||
| 76 | 0 | for my $nf (0..$fields-1) { # loop over dicom fields | |||||||||||||||||||||||||||
| 77 | 0 | my ($name,$vm,$vr,$syngodt,$nitems,$chk)=unpack('a64La4LLL',$str); | |||||||||||||||||||||||||||
| 78 | 0 | $str=substr($str,84,); # chop away | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | die "This is not a dicom field $chk\n" unless ($chk == 77 || $chk == 205); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$chk == 77 or $chk == 205
MC/DC0%0/2
$chk == 77 or $chk == 205
$chk == 77
$chk == 205
Truth table0%0/3
A or B
A= $chk == 77B= $chk == 205
| |||||||||||||||||||||||||||||
| 80 | 0 | ($name,my($rest))=split "\0",$name; | |||||||||||||||||||||||||||
| 81 | 0 | my @data; | |||||||||||||||||||||||||||
| 82 | 0 | for my $ni (0..$nitems-1) { | |||||||||||||||||||||||||||
| 83 | 0 | my @header = unpack ('L4',$str); | |||||||||||||||||||||||||||
| 84 | #print "header @header\n"; | ||||||||||||||||||||||||||||
| 85 | 0 | $chk=$header[2]; | |||||||||||||||||||||||||||
| 86 | 0 | ▶ | die "This is not a dicom csa field $chk\n" unless ($chk == 77 || $chk == 205); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$chk == 77 or $chk == 205
MC/DC0%0/2
$chk == 77 or $chk == 205
$chk == 77
$chk == 205
Truth table0%0/3
A or B
A= $chk == 77B= $chk == 205
| |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | die "Not a CSA field @header\n" if ($header[0]!=$header[1] && $header[0]!=$header[3]); # all equal | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$header[0] != $header[1] and $header[0] != $header[3]
MC/DC0%0/2
$header[0] != $header[1] and $header[0] != $header[3]
$header[0] != $header[1]
$header[0] != $header[3]
Truth table0%0/3
A and B
A= $header[0] != $header[1]B= $header[0] != $header[3]
| |||||||||||||||||||||||||||||
| 88 | 0 | $str=substr($str,16,); | |||||||||||||||||||||||||||
| 89 | 0 | (@data[$ni],$rest)=split ("\0",unpack("a$header[0]",$str)); | |||||||||||||||||||||||||||
| 90 | 0 | $str=substr($str,4*ceil($header[0]/4),); # chop away | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | #print "csa: field $name, value @data vm $vm\n"; # if ($name =~ /Image/); | ||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if ($vm == 1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 94 | 0 | $$csa{$name}=$data[0]; | |||||||||||||||||||||||||||
| 95 | #print "csa->$name: ", $$csa{$name},"\n"; | ||||||||||||||||||||||||||||
| 96 | #} elsif ($vr =~m/CS|LO|LT|SH|SS|UI|UT|UN/) { | ||||||||||||||||||||||||||||
| 97 | # $$csa{$name}=\@data[0..$vm-1]; | ||||||||||||||||||||||||||||
| 98 | #} elsif ( $vr =~ m/DS|FD|FL|IS|SL|ST|UL|US/) { | ||||||||||||||||||||||||||||
| 99 | # $$csa{$name}=pdl(@data[0..$vm-1]); | ||||||||||||||||||||||||||||
| 100 | } elsif ( $vm>1 ) { | ||||||||||||||||||||||||||||
| 101 | 0 | $$csa{$name}=[@data[0..$vm-1]]; | |||||||||||||||||||||||||||
| 102 | } else { | ||||||||||||||||||||||||||||
| 103 | 0 | $$csa{$name}=[@data[0..$nitems-1]]; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | #print "name $name, dumping CSA:\n"; | ||||||||||||||||||||||||||||
| 106 | #print Dumper $csa; | ||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | #$DB::single=1; | ||||||||||||||||||||||||||||
| 109 | #print "Dumping csa structure: \n"; | ||||||||||||||||||||||||||||
| 110 | #print Dumper $csa; | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub read_text_hdr { | ||||||||||||||||||||||||||
|
Subroutine
read_text_hdr: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | 0 | my $f=shift; # File | |||||||||||||||||||||||||||
| 115 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 116 | 0 | ▶ | open (HDR,'<',\$f) || die "no header !"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | my $l; | |||||||||||||||||||||||||||
| 118 | #say "file $f line $l"; | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | do {$l=<HDR>; } until ($l=~/ASCCONV BEGIN/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | while (($l=<HDR>)!~/ASCCONV END/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 0 | chomp $l; | |||||||||||||||||||||||||||
| 122 | 0 | ▶ | if ( $l) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 0 | chomp (my ($key,$val)=split /\s*=\s*/,$l); | |||||||||||||||||||||||||||
| 124 | 0 | chomp($key); | |||||||||||||||||||||||||||
| 125 | 0 | $key=~s/[\[\].]/_/g; | |||||||||||||||||||||||||||
| 126 | 0 | $self->hdr->{ascconv}->{$key}=$val; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | 0 | close HDR; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub create_data { | ||||||||||||||||||||||||||
|
Subroutine
create_data: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 133 | 0 | my $data_ref=$_[0]; | |||||||||||||||||||||||||||
| 134 | 0 | my $opt=$_[1]; | |||||||||||||||||||||||||||
| 135 | 0 | my $data=PDL::IO::Dcm::create_image_data(@_); | |||||||||||||||||||||||||||
| 136 | 0 | ▶ | my $ref=$$data_ref{first { not /^dims$/ } (keys %$data_ref)}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 137 | #say join ', ', keys %$data_ref; | ||||||||||||||||||||||||||||
| 138 | 0 | my $dims=$$data_ref{dims}; | |||||||||||||||||||||||||||
| 139 | # get one dicom, need to exclude the dims key | ||||||||||||||||||||||||||||
| 140 | 0 | my $plugin=$ref->hdr->{plugin}; | |||||||||||||||||||||||||||
| 141 | 0 | ▶ | die "create_data: no plugin\n" unless $plugin; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | my $order=$$opt{$plugin}->{dim_order}; | |||||||||||||||||||||||||||
| 143 | #say "dims(order) ",$dims($order); | ||||||||||||||||||||||||||||
| 144 | 0 | my $header=dclone($ref->hdr); | |||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | #$header->{Dimensions}=$$opt{$plugin}->{Dimensons}; | ||||||||||||||||||||||||||||
| 148 | #$header->{dim_order}=$$opt{$plugin}->{dim_order}; # get through $$opt{plugin} | ||||||||||||||||||||||||||||
| 149 | 0 | $header->{dim_idx}=$$opt{$plugin}->{dim_idx}; | |||||||||||||||||||||||||||
| 150 | #$header->{key_list}=$$opt{$plugin}->{key_list}; | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | for my $key (@key_list) { | |||||||||||||||||||||||||||
| 153 | 0 | $header->{dicom}->{$key}=zeroes(list $dims($order)); | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | # get a reference to the header | ||||||||||||||||||||||||||||
| 156 | # the diff container holds all fields that are not equal for all dicom instances | ||||||||||||||||||||||||||||
| 157 | 0 | $header->{diff}={}; | |||||||||||||||||||||||||||
| 158 | # copy dimensions and create keys for each | ||||||||||||||||||||||||||||
| 159 | # prepare geometry and other data structures | ||||||||||||||||||||||||||||
| 160 | 0 | $header->{dicom}->{'Image Orientation (Patient)'}=zeroes(6,list $dims($order)); | |||||||||||||||||||||||||||
| 161 | 0 | $header->{dicom}->{'Image Position (Patient)'}=zeroes(3,list $dims($order)); | |||||||||||||||||||||||||||
| 162 | 0 | $header->{dicom}->{'Pixel Spacing'}=zeroes(2,list $dims($order)); | |||||||||||||||||||||||||||
| 163 | #say $header->{dicom}->{'Pixel Spacing'}; | ||||||||||||||||||||||||||||
| 164 | #$header->{dim_idx}={}; | ||||||||||||||||||||||||||||
| 165 | 0 | $header->{dcm_key}={}; | |||||||||||||||||||||||||||
| 166 | 0 | return($data,$header); | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub fill_data { | ||||||||||||||||||||||||||
|
Subroutine
fill_data: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 170 | #PDL::IO::Dcm::fill_image_data(@_); | ||||||||||||||||||||||||||||
| 171 | 0 | my $data=shift; | |||||||||||||||||||||||||||
| 172 | 0 | my $header=$data->hdr; | |||||||||||||||||||||||||||
| 173 | 0 | my $dcm=shift; | |||||||||||||||||||||||||||
| 174 | 0 | my $ref=shift; | |||||||||||||||||||||||||||
| 175 | 0 | my $opt=shift; | |||||||||||||||||||||||||||
| 176 | 0 | my $plugin=$dcm->hdr->{plugin}; | |||||||||||||||||||||||||||
| 177 | 0 | my $order=$$opt{$plugin}->{dim_order}; | |||||||||||||||||||||||||||
| 178 | #print "dcm: ",$dcm->hdr->{dim_idx},", data ",$data->info,"\n"; | ||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ($dcm->hdr->{tp}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 0 | $data(,,list( $dcm->hdr->{dim_idx}->($order)-1)) | |||||||||||||||||||||||||||
| 181 | .=$dcm->transpose;} | ||||||||||||||||||||||||||||
| 182 | 0 | else {$data(,,list ($dcm->hdr->{dim_idx}->($order)-1)).=$dcm;} | |||||||||||||||||||||||||||
| 183 | # now fill all the header data | ||||||||||||||||||||||||||||
| 184 | 0 | for my $key (@{$$opt{$plugin}->{key_list}}) { | |||||||||||||||||||||||||||
| 185 | 0 | $dcm->hdr->{dicom}->{$key}; | |||||||||||||||||||||||||||
| 186 | $header->{dicom}->{$key}->(list ($dcm->hdr->{dim_idx}->($order)-1)) | ||||||||||||||||||||||||||||
| 187 | 0 | .=$dcm->hdr->{dicom}->{$key}; | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | # preserve original info | ||||||||||||||||||||||||||||
| 190 | #print "IDX: ",$dcm->hdr->{dim_idx}; | ||||||||||||||||||||||||||||
| 191 | 0 | $header->{dim_idx}->{$dcm->hdr->{dcm_key}}=$dcm->hdr->{dim_idx}; | |||||||||||||||||||||||||||
| 192 | $header->{dcm_key}->{join ('_',list ($dcm->hdr->{dim_idx}->($order)))} | ||||||||||||||||||||||||||||
| 193 | 0 | =$dcm->hdr->{dcm_key}; | |||||||||||||||||||||||||||
| 194 | $header->{dicom}->{'Image Orientation (Patient)'}->(,list ($dcm->hdr->{dim_idx}->($order)-1)) | ||||||||||||||||||||||||||||
| 195 | 0 | .=pdl (split /\\/,$dcm->hdr->{dicom}->{'Image Orientation (Patient)'}); | |||||||||||||||||||||||||||
| 196 | #say split /\\/,$dcm->hdr->{dicom}->{'Pixel Spacing'}; | ||||||||||||||||||||||||||||
| 197 | #say $header->{dicom}->{'Pixel Spacing'}->(,list($dcm->hdr->{dim_idx}->{$order})); | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | #say $header->{dicom}->{'Pixel Spacing'}; | ||||||||||||||||||||||||||||
| 200 | $header->{dicom}->{'Pixel Spacing'}->(,list $dcm->hdr->{dim_idx}->($order)-1) | ||||||||||||||||||||||||||||
| 201 | 0 | .=pdl (split /\\/,$dcm->hdr->{dicom}->{'Pixel Spacing'}); | |||||||||||||||||||||||||||
| 202 | $header->{dicom}->{'Image Position (Patient)'}->(,list $dcm->hdr->{dim_idx}->($order)-1) | ||||||||||||||||||||||||||||
| 203 | 0 | .=pdl (split /\\/,$dcm->hdr->{dicom}->{'Image Position (Patient)'}); | |||||||||||||||||||||||||||
| 204 | 0 | for my $field (keys %{$dcm->hdr->{dicom}}) { | |||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ($dcm->hdr->{dicom}->{$field} ne $ref->hdr->{dicom}->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | $header->{diff}->{$field}={} | ||||||||||||||||||||||||||||
| 207 | 0 | ▶ | unless ref ($header->{diff}->{$field}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | for my $key (@key_list_csa) { | |||||||||||||||||||||||||||
| 212 | 0 | $dcm->hdr->{csa}->{$key}; | |||||||||||||||||||||||||||
| 213 | $header->{csa}->{$key}->(list $dcm->hdr->{dim_idx}->($order)) | ||||||||||||||||||||||||||||
| 214 | 0 | .=$dcm->hdr->{csa}->{$key}; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | 0 | ▶ | $header->{diff}->{csa}={} unless ref ($header->{diff}->{csa}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | 0 | for my $field (keys %{$dcm->hdr->{csa}}) { | |||||||||||||||||||||||||||
| 218 | 0 | ▶ | if ($dcm->hdr->{csa}->{$field} ne $ref->hdr->{csa}->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | $header->{diff}->{csa}->{$field}={} | ||||||||||||||||||||||||||||
| 220 | 0 | ▶ | unless ref ($header->{diff}->{csa}->{$field}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | ▶ | sub parser{ | ||||||||||||||||||||||||||
|
Subroutine
parser: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 226 | 0 | PDL::IO::Dcm::image_parser(@_); | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub read_dcm { | ||||||||||||||||||||||||||
|
Subroutine
read_dcm: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 230 | # This is to refer to the MRSSiemens plugin if necessary. | ||||||||||||||||||||||||||||
| 231 | 0 | my $dcm=shift; | |||||||||||||||||||||||||||
| 232 | 0 | my $opt=shift; | |||||||||||||||||||||||||||
| 233 | 0 | my $pdl=shift; | |||||||||||||||||||||||||||
| 234 | 0 | ▶ | require PDL::IO::Dcm::Plugins::MRSSiemens || return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 0 | $opt=PDL::IO::Dcm::Plugins::MRSSiemens::setup_dcm($opt); | |||||||||||||||||||||||||||
| 236 | 0 | say "Processing Series ".$dcm->getValue('SeriesNumber'); | |||||||||||||||||||||||||||
| 237 | 0 | my $pdl=PDL::IO::Dcm::Plugins::MRSSiemens::read_dcm($dcm,$opt,$pdl); | |||||||||||||||||||||||||||
| 238 | 0 | $pdl; | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub sort_protid { | ||||||||||||||||||||||||||
|
Subroutine
sort_protid: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 242 | 0 | $_[0]->hdr->{ascconv}->{"lProtID"}; | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub map_slicegroup { | ||||||||||||||||||||||||||
|
Subroutine
map_slicegroup: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 246 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 247 | # number of slice groups | ||||||||||||||||||||||||||||
| 248 | 0 | my $lsize=$self->hdr->{ascconv}->{sGroupArray_lSize}; | |||||||||||||||||||||||||||
| 249 | #say "map: $lsize"; | ||||||||||||||||||||||||||||
| 250 | # size of each slice group | ||||||||||||||||||||||||||||
| 251 | 0 | ▶ | my $sg_size=pdl[ map {$self->hdr->{ascconv}->{"sGroupArray_asGroup_${_}__nSize"}||1} | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->hdr->{'ascconv'}{"sGroupArray_asGroup_${_}__nSize"} || 1
MC/DC0%0/1
$self->hdr->{'ascconv'}{"sGroupArray_asGroup_${_}__nSize"} || 1
$self->hdr->{'ascconv'}{"sGroupArray_asGroup_${_}__nSize"}
Truth table0%0/2
A
A= $self->hdr->{'ascconv'}{"sGroupArray_asGroup_${_}__nSize"}
| |||||||||||||||||||||||||||||
| 252 | (0..$lsize-1_)]; | ||||||||||||||||||||||||||||
| 253 | # start of each slice group | ||||||||||||||||||||||||||||
| 254 | 0 | ▶ | my $sg_start=pdl[ map {$self->hdr->{ascconv}->{"sGroupArray_asGroup_${_}__nLow"}||0} | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->hdr->{'ascconv'}{"sGroupArray_asGroup_${_}__nLow"} || 0
MC/DC0%0/1
$self->hdr->{'ascconv'}{"sGroupArray_asGroup_${_}__nLow"} || 0
$self->hdr->{'ascconv'}{"sGroupArray_asGroup_${_}__nLow"}
Truth table0%0/2
A
A= $self->hdr->{'ascconv'}{"sGroupArray_asGroup_${_}__nLow"}
| |||||||||||||||||||||||||||||
| 255 | (0..$lsize-1)]; | ||||||||||||||||||||||||||||
| 256 | # lowest and highest slice index mapped via SliceArray anAsc | ||||||||||||||||||||||||||||
| 257 | 0 | ▶ | my ($mi,$ma)= minmax pdl[ map{ $self->hdr->{ascconv}->{"sSliceArray_anAsc_${_}_"}||0} | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->hdr->{'ascconv'}{"sSliceArray_anAsc_${_}_"} || 0
MC/DC0%0/1
$self->hdr->{'ascconv'}{"sSliceArray_anAsc_${_}_"} || 0
$self->hdr->{'ascconv'}{"sSliceArray_anAsc_${_}_"}
Truth table0%0/2
A
A= $self->hdr->{'ascconv'}{"sSliceArray_anAsc_${_}_"}
| |||||||||||||||||||||||||||||
| 258 | # 10 is slices | ||||||||||||||||||||||||||||
| 259 | 0 | map {$_->(10,;-) } values( %{$self->hdr->{dim_idx}})]; | |||||||||||||||||||||||||||
| 260 | #say "size $sg_size start $sg_start mi, ma $mi $ma"; | ||||||||||||||||||||||||||||
| 261 | 0 | my $low=sclr which($sg_start==$mi); | |||||||||||||||||||||||||||
| 262 | 0 | my $high=sclr which($sg_start+$sg_size-1==$ma); | |||||||||||||||||||||||||||
| 263 | barf "Start and end don't match definition start: ($mi) $low, end: ($ma) $high for", | ||||||||||||||||||||||||||||
| 264 | 0 | ▶ | $self->hdr->{dcm_key},"!\n" if ($high != $low); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | #say " $low,$sg_size($low),$sg_start($low)"; | ||||||||||||||||||||||||||||
| 267 | 0 | return $low,sclr ($sg_size($low)),sclr ($sg_start($low)); | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub populate_header { | ||||||||||||||||||||||||||
|
Subroutine
populate_header: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 271 | 0 | my $dicom =shift; | |||||||||||||||||||||||||||
| 272 | 0 | my $piddle=shift; | |||||||||||||||||||||||||||
| 273 | 0 | my $opt=shift; | |||||||||||||||||||||||||||
| 274 | 0 | my $csa={}; | |||||||||||||||||||||||||||
| 275 | 0 | my @ret; | |||||||||||||||||||||||||||
| 276 | my $iced; | ||||||||||||||||||||||||||||
| 277 | # The protocol is in here: | ||||||||||||||||||||||||||||
| 278 | 0 | $piddle->hdr->{csa}={}; # create empty hash | |||||||||||||||||||||||||||
| 279 | 0 | read_text_hdr($dicom->getValue ('0029,1020','native'),$piddle); | |||||||||||||||||||||||||||
| 280 | 0 | read_csa($dicom->getValue ('0029,1010','native'),$piddle); | |||||||||||||||||||||||||||
| 281 | #read_csa($dicom->getValue ('0029,1210','native'),$piddle); | ||||||||||||||||||||||||||||
| 282 | 0 | read_csa($dicom->getValue ('0029,1020','native'),$piddle); | |||||||||||||||||||||||||||
| 283 | 0 | delete $piddle->hdr->{raw_dicom}->{'0029,1020'}; # Protocol | |||||||||||||||||||||||||||
| 284 | 0 | @ret=$dicom->getValue('0029,1010','native')=~/ICE_Dims.{92}((_?(X|\d+)){13})/s; | |||||||||||||||||||||||||||
| 285 | 0 | (my $str=$ret[0])=~s/X/1/e; | |||||||||||||||||||||||||||
| 286 | 0 | my @d=split ('_',$str); | |||||||||||||||||||||||||||
| 287 | 0 | $iced=pdl(short,@d); #badvalue(short)/er)]); | |||||||||||||||||||||||||||
| 288 | #$iced--; | ||||||||||||||||||||||||||||
| 289 | 0 | $piddle->hdr->{dim_idx}=$iced; | |||||||||||||||||||||||||||
| 290 | # to make this unique | ||||||||||||||||||||||||||||
| 291 | #say "Series Number ",$dicom->getValue('SeriesNumber'), | ||||||||||||||||||||||||||||
| 292 | 0 | "Instance Number ",$dicom->getValue('InstanceNumber'); | |||||||||||||||||||||||||||
| 293 | #$piddle->hdr->{dcm_key}=$dicom->getValue('InstanceNumber').'_'.($dicom->getValue('0051,100f')||0); | ||||||||||||||||||||||||||||
| 294 | 0 | $piddle->hdr->{dcm_key}=$dicom->getValue('SOPInstanceUID'); #.'_'.($dicom->getValue('0051,100f')||0); | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub handle_duplicates { | ||||||||||||||||||||||||||
|
Subroutine
handle_duplicates: not called CC=1 SCAR=2.2
Pod
documented
| |||||||||||||||||||||||||||||
| 298 | 0 | my $stack=shift; | |||||||||||||||||||||||||||
| 299 | 0 | my $dcm=shift; | |||||||||||||||||||||||||||
| 300 | 0 | my $opt=shift; | |||||||||||||||||||||||||||
| 301 | 2 | ▶ | no PDL::NiceSlice; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 302 | 0 | my $plugin=$dcm->hdr->{plugin}; | |||||||||||||||||||||||||||
| 303 | 0 | my $o=$$opt{$plugin}->{dim_order}; | |||||||||||||||||||||||||||
| 304 | 0 | my $list=$dcm->hdr->{dim_idx}; | |||||||||||||||||||||||||||
| 305 | 2 | ▶ | use PDL::NiceSlice; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 306 | 0 | $list=list($list($o)); | |||||||||||||||||||||||||||
| 307 | 0 | warn "Duplicates detected in scan ".$dcm->hdr->{dicom}->{"Series Number"}."\n"; | |||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 0 | warn "This entry (". $dcm->hdr->{dim_idx}->($$opt{$plugin}->{dim_order}). | |||||||||||||||||||||||||||
| 310 | max ($stack->(,,)). | ||||||||||||||||||||||||||||
| 311 | ") is already set! This should not happen, please file a bug report!\n"; | ||||||||||||||||||||||||||||
| 312 | 0 | $stack; | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub init_dims { | ||||||||||||||||||||||||||
|
Subroutine
init_dims: not called CC=27 SCAR=66.3
Pod
documented
| |||||||||||||||||||||||||||||
| 316 | use PDL::NiceSlice; | ||||||||||||||||||||||||||||
| 317 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 318 | 0 | my $opt=shift; | |||||||||||||||||||||||||||
| 319 | # shortcut to dicom field | ||||||||||||||||||||||||||||
| 320 | 0 | my $dm=$self->hdr->{dicom}; | |||||||||||||||||||||||||||
| 321 | 0 | say $dm->{"Image Position (Patient)"}->info; | |||||||||||||||||||||||||||
| 322 | # we need these modules, return undef otherwise. | ||||||||||||||||||||||||||||
| 323 | 0 | ▶ | require PDL::Dims || return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | 0 | ▶ | require PDL::Transform || return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 325 | 0 | PDL::Dims->import(qw/is_equidistant dmin dmax vals hpar dinc initdim dimsize drot idx diminfo /); | |||||||||||||||||||||||||||
| 326 | #say "init_dims: ",$self->hdr->{dcm_key}; | ||||||||||||||||||||||||||||
| 327 | #say "init_dims: ",$self->hdr->{dicom}->{Rows} ; | ||||||||||||||||||||||||||||
| 328 | #say "init_dims: hpar ",hpar($self,'dicom','Rows'); | ||||||||||||||||||||||||||||
| 329 | 0 | PDL::Transform->import(qw/t_linear/); | |||||||||||||||||||||||||||
| 330 | #say diminfo ($self),$self->hdr->{ascconv}->{sGroupArray_asGroup_1__nSize}; | ||||||||||||||||||||||||||||
| 331 | # center=inner(rot*scale,dim/2)+Image Position (Patient) | ||||||||||||||||||||||||||||
| 332 | # xf=t_linear(matrix=>Pixel Scale*$rot->transpose,post=>Image Position (Patient)) | ||||||||||||||||||||||||||||
| 333 | 0 | ▶ | if (hpar($self,'ascconv','sGroupArray_asGroup_1__nSize')){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 334 | 0 | warn "Multiple slice groups, support dubious!"; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | use PDL::NiceSlice; | ||||||||||||||||||||||||||||
| 337 | #my $v=zeroes(3); | ||||||||||||||||||||||||||||
| 338 | # This needs to be converted to dicom fields for navs ... | ||||||||||||||||||||||||||||
| 339 | # Center of FOV | ||||||||||||||||||||||||||||
| 340 | 0 | my $dims=$self->hdr->{dicom}->{"Image Orientation (Patient)"}->shape; | |||||||||||||||||||||||||||
| 341 | 0 | my @li=( 3,2,list ( $dims->slice("1:"))); | |||||||||||||||||||||||||||
| 342 | 0 | my $sh= $self->hdr->{dicom}->{"Image Orientation (Patient)"}->reshape(@li); | |||||||||||||||||||||||||||
| 343 | 0 | my $w= $self->hdr->{dicom}->{"Pixel Spacing"}->dummy(0,1)*$sh; | |||||||||||||||||||||||||||
| 344 | 0 | my $vv=($self->hdr->{dicom}->{Columns}*$w->slice(",0")+$self->hdr->{dicom}->{Rows}*$w->slice(",1"))->clump(0,1); | |||||||||||||||||||||||||||
| 345 | 0 | my $v=$vv/2+$self->hdr->{dicom}->{"Image Position (Patient)"}; #->transpose; | |||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | #$v(0,).=hpar($self,'ascconv','sSliceArray_asSlice_0__sPosition_dSag') ||0; #x | ||||||||||||||||||||||||||||
| 348 | #$v(1,).=hpar($self,'ascconv','sSliceArray_asSlice_0__sPosition_dCor') ||0; #y | ||||||||||||||||||||||||||||
| 349 | #$v(2,).=hpar($self,'ascconv','sSliceArray_asSlice_0__sPosition_dTra') ||0; #z | ||||||||||||||||||||||||||||
| 350 | #say $v; | ||||||||||||||||||||||||||||
| 351 | #say "hpar: pos ",hpar($self,'dicom','Image Position (Patient)'), | ||||||||||||||||||||||||||||
| 352 | #$self->hdr->{dicom}->{'Image Position (Patient)'}; | ||||||||||||||||||||||||||||
| 353 | #say "init_dims: ",hpar($self,'dicom','Rows'); | ||||||||||||||||||||||||||||
| 354 | 0 | my $pos_d; | |||||||||||||||||||||||||||
| 355 | 0 | $pos_d=(hpar($self,'dicom','Image Position (Patient)'))->flat->(:2); #->uniq; | |||||||||||||||||||||||||||
| 356 | #my $ir=hpar($self,'ascconv','sSliceArray_asSlice_0__dInPlaneRot') ||0; #radiant | ||||||||||||||||||||||||||||
| 357 | 0 | my $or=pdl(hpar($self,'dicom','Image Orientation (Patient)'))->flat->(:5) | |||||||||||||||||||||||||||
| 358 | ->reshape(3,2)->transpose; # | ||||||||||||||||||||||||||||
| 359 | 0 | my $pe_dir=hpar($self,'dicom','In-plane Phase Encoding Direction'); | |||||||||||||||||||||||||||
| 360 | # Scaling | ||||||||||||||||||||||||||||
| 361 | # Rotation | ||||||||||||||||||||||||||||
| 362 | 0 | my $srot=zeroes(3,3); | |||||||||||||||||||||||||||
| 363 | 0 | $srot(:1,).=$or; | |||||||||||||||||||||||||||
| 364 | 0 | $srot(2,;-).=crossp($or(1,;-),$or(0,;-)); | |||||||||||||||||||||||||||
| 365 | 0 | ▶ | $srot(2,;-).=pdl[0,0,1] unless any ($srot(2,;-)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | #say "spatial rotation $srot"; | ||||||||||||||||||||||||||||
| 367 | #$pos_d=$pos_d(,0;-); | ||||||||||||||||||||||||||||
| 368 | # Calculate and initialise the transformation | ||||||||||||||||||||||||||||
| 369 | 0 | my @ors=qw/Sag Cor Tra/; | |||||||||||||||||||||||||||
| 370 | 0 | say $srot; | |||||||||||||||||||||||||||
| 371 | 0 | $self->hdr->{orientation}=$ors[maximum_ind(abs($srot(2;-)))]; # normal vector lookup | |||||||||||||||||||||||||||
| 372 | my $pe=$self->hdr->{dicom}->{"In-plane Phase Encoding Direction"} | ||||||||||||||||||||||||||||
| 373 | 0 | ▶ | ||$self->hdr->{dicom}->{"InPlanePhaseEncodingDirection"}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->hdr->{'dicom'}{'In-plane Phase Encoding Direction'} || $self->hdr->{'dicom'}{'InPlanePhaseEncodingDirection'}
MC/DC0%0/2
$self->hdr->{'dicom'}{'In-plane Phase Encoding Direction'} || $self->hdr->{'dicom'}{'InPlanePhaseEncodingDirection'}
$self->hdr->{'dicom'}{'In-plane Phase Encoding Direction'}
$self->hdr->{'dicom'}{'InPlanePhaseEncodingDirection'}
Truth table0%0/3
A || B
A= $self->hdr->{'dicom'}{'In-plane Phase Encoding Direction'}B= $self->hdr->{'dicom'}{'InPlanePhaseEncodingDirection'}
| |||||||||||||||||||||||||||||
| 374 | 0 | ▶ | if ($self->hdr->{orientation} eq 'Tra'){ # transversal slice | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | #say $self->hdr->{orientation}. " Orientation"; | ||||||||||||||||||||||||||||
| 376 | 0 | $self->hdr->{sl}='z'; | |||||||||||||||||||||||||||
| 377 | 0 | ▶ | if ($pe eq 'COL'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 378 | 0 | $self->hdr->{ro}='x'; | |||||||||||||||||||||||||||
| 379 | 0 | $self->hdr->{pe}='y'; | |||||||||||||||||||||||||||
| 380 | } else { | ||||||||||||||||||||||||||||
| 381 | 0 | $self->hdr->{ro}='y'; | |||||||||||||||||||||||||||
| 382 | 0 | $self->hdr->{pe}='x'; | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if ($self->hdr->{orientation} eq 'Cor'){ # coronal slice | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 386 | 0 | $self->hdr->{sl}='y'; | |||||||||||||||||||||||||||
| 387 | 0 | ▶ | if ($pe eq 'COL') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 388 | 0 | $self->hdr->{ro}='x'; | |||||||||||||||||||||||||||
| 389 | 0 | $self->hdr->{pe}='z'; | |||||||||||||||||||||||||||
| 390 | } else { | ||||||||||||||||||||||||||||
| 391 | 0 | $self->hdr->{ro}='z'; | |||||||||||||||||||||||||||
| 392 | 0 | $self->hdr->{pe}='x'; | |||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if ($self->hdr->{orientation} eq 'Sag'){ # sagittal slice | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | 0 | $self->hdr->{sl}='x'; | |||||||||||||||||||||||||||
| 397 | 0 | ▶ | if ($pe eq 'COL') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 398 | 0 | $self->hdr->{ro}='y'; | |||||||||||||||||||||||||||
| 399 | 0 | $self->hdr->{pe}='z'; | |||||||||||||||||||||||||||
| 400 | } else { | ||||||||||||||||||||||||||||
| 401 | 0 | $self->hdr->{ro}='z'; | |||||||||||||||||||||||||||
| 402 | 0 | $self->hdr->{pe}='y'; | |||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | 0 | my $s=zeroes(3); # matrix size | |||||||||||||||||||||||||||
| 406 | #my $fov=zeroes(3); # FOV | ||||||||||||||||||||||||||||
| 407 | #$fov(0).=$self->hdr->{ascconv}->{sSliceArray_asSlice_0__dReadoutFOV}; | ||||||||||||||||||||||||||||
| 408 | #$fov(1).=$self->hdr->{ascconv}->{sSliceArray_asSlice_0__dPhaseFOV}; | ||||||||||||||||||||||||||||
| 409 | 0 | $s(0).=$self->dim(0); | |||||||||||||||||||||||||||
| 410 | 0 | $s(1).=$self->dim(1); | |||||||||||||||||||||||||||
| 411 | #if ($pe =~ 'COL') { | ||||||||||||||||||||||||||||
| 412 | # $s(0).=$self->hdr->{csa}->{Columns}; | ||||||||||||||||||||||||||||
| 413 | # $s(1).=$self->hdr->{csa}->{Rows}; | ||||||||||||||||||||||||||||
| 414 | #say "COL! $s"; | ||||||||||||||||||||||||||||
| 415 | #} else { | ||||||||||||||||||||||||||||
| 416 | # $s(1).=$self->hdr->{dicom}->{Width}||$self->hdr->{dicom}->{Columns}; | ||||||||||||||||||||||||||||
| 417 | # $s(0).=$self->hdr->{dicom}->{Height}||$self->hdr->{dicom}->{Rows}; | ||||||||||||||||||||||||||||
| 418 | #$fov(1).=$self->hdr->{ascconv}->{sSliceArray_asSlice_0__dReadoutFOV}; | ||||||||||||||||||||||||||||
| 419 | #$fov(0).=$self->hdr->{ascconv}->{sSliceArray_asSlice_0__dPhaseFOV}; | ||||||||||||||||||||||||||||
| 420 | #} | ||||||||||||||||||||||||||||
| 421 | #say "PE $pe $s $fov " ; | ||||||||||||||||||||||||||||
| 422 | 0 | $s(2).=1; | |||||||||||||||||||||||||||
| 423 | # Slice groups! | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | #if ($$opt{split}) { | ||||||||||||||||||||||||||||
| 427 | #my ($sg,$size)=map_slicegroup($self); | ||||||||||||||||||||||||||||
| 428 | #$s(2).=$self->hdr->{dicom}->{"Image Orientation (Patient)"}->dim(1); | ||||||||||||||||||||||||||||
| 429 | #} else { | ||||||||||||||||||||||||||||
| 430 | #$s(2)*=$self->hdr->{ascconv}->{'sSliceArray_lSize'}; | ||||||||||||||||||||||||||||
| 431 | 0 | $s(2).=$self->hdr->{dicom}->{'Image Orientation (Patient)'}->dim(2); | |||||||||||||||||||||||||||
| 432 | #} | ||||||||||||||||||||||||||||
| 433 | $self->hdr->{'3d'}=1 if (($self->hdr->{dicom}->{MRAcquisitionType}|| | ||||||||||||||||||||||||||||
| 434 | 0 | ▶ | hpar($self,'dicom','MR Acquisition Type')) eq '3D'); # 3D | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->hdr->{'dicom'}{'MRAcquisitionType'} || hpar($self, 'dicom', 'MR Acquisition Type')
MC/DC0%0/2
$self->hdr->{'dicom'}{'MRAcquisitionType'} || hpar($self, 'dicom', 'MR Acquisition Type')
$self->hdr->{'dicom'}{'MRAcquisitionType'}
hpar($self, 'dicom', 'MR Acquisition Type')
Truth table0%0/3
A || B
A= $self->hdr->{'dicom'}{'MRAcquisitionType'}B= hpar($self, 'dicom', 'MR Acquisition Type')
| |||||||||||||||||||||||||||||
| 435 | 0 | ▶ | if ($self->hdr->{'3d'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 436 | #$s(2).=$self->hdr->{ascconv}->{'sKSpace_lImagesPerSlab'} ; | ||||||||||||||||||||||||||||
| 437 | #$fov(2).=$self->hdr->{ascconv}->{sSliceArray_asSlice_0__dThickness}; | ||||||||||||||||||||||||||||
| 438 | } else { | ||||||||||||||||||||||||||||
| 439 | #$fov(2).=$self->hdr->{dicom}->{"Spacing Between Slices"}*$s(2) | ||||||||||||||||||||||||||||
| 440 | # ||$self->hdr->{ascconv}->{'sSliceArray_asSlice_0__dThickness'}; | ||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||
| 442 | #$s(2).=1 if ($s(2)<1); | ||||||||||||||||||||||||||||
| 443 | #say "FOV $fov matrix $s"; | ||||||||||||||||||||||||||||
| 444 | 0 | my $rot=identity($self->ndims); | |||||||||||||||||||||||||||
| 445 | 0 | my $inc_d=zeroes(3); | |||||||||||||||||||||||||||
| 446 | #say "Pixel Spacing", hpar($self,'dicom','Pixel Spacing'); | ||||||||||||||||||||||||||||
| 447 | 0 | $inc_d(:1).=hpar($self,'dicom','Pixel Spacing')->(:1;-); | |||||||||||||||||||||||||||
| 448 | 0 | my $p=$self->hdr->{dicom}->{"Image Position (Patient)"}; | |||||||||||||||||||||||||||
| 449 | 0 | say "Imae Position ".$pos_d; | |||||||||||||||||||||||||||
| 450 | 0 | $inc_d(2).=$dm->{"Spacing Between Slices"}; | |||||||||||||||||||||||||||
| 451 | #$inc_d(2).=average sumover (sqrt( $p(",2:,")-$p->slice(",:-2,"))**2); | ||||||||||||||||||||||||||||
| 452 | #$inc_d(2).=$fov(2,0)/$s(2,0); | ||||||||||||||||||||||||||||
| 453 | #say $srot; | ||||||||||||||||||||||||||||
| 454 | 0 | $rot(:2,:2).=$srot; | |||||||||||||||||||||||||||
| 455 | #say "FOV $fov matrix $s, pixels $inc_d"; | ||||||||||||||||||||||||||||
| 456 | 0 | ▶ | barf $self->hdr->{dicom}->{'Series Number'},": dims don't fit! $s vs. ",$self->shape->(:2) if any($self->shape->(:2)-$s); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 457 | #say "Rot: $rot"; | ||||||||||||||||||||||||||||
| 458 | 0 | say "orientation : ",hpar($self,'orientation'); #,diminfo ($self); | |||||||||||||||||||||||||||
| 459 | 0 | say "scaling / inc ",$inc_d; | |||||||||||||||||||||||||||
| 460 | 0 | say "x ",getx($self->hdr),", y ",gety($self->hdr),", z ",getz($self->hdr); | |||||||||||||||||||||||||||
| 461 | #initdim($self,'x',size=>$s(0),min=>sclr($pos_d(0)),inc=>sclr($inc_d(0)),unit=>'mm'); | ||||||||||||||||||||||||||||
| 462 | #initdim($self,'y',size=>$s(1),min=>sclr($pos_d(1)),inc=>sclr($inc_d(1)),unit=>'mm'); | ||||||||||||||||||||||||||||
| 463 | #initdim($self,'z',size=>$s(2),min=>sclr($pos_d(2)),inc=>sclr($inc_d(2)),unit=>'mm'); | ||||||||||||||||||||||||||||
| 464 | #if ($pe eq 'COL') { | ||||||||||||||||||||||||||||
| 465 | 0 | initdim($self,getx($self->hdr),size=>$s(0),min=>sclr($pos_d(0)),inc=>sclr($inc_d(0)),unit=>'mm'); | |||||||||||||||||||||||||||
| 466 | 0 | initdim($self,gety($self->hdr),size=>$s(1),min=>sclr($pos_d(1)),inc=>sclr($inc_d(1)),unit=>'mm'); | |||||||||||||||||||||||||||
| 467 | #} else { | ||||||||||||||||||||||||||||
| 468 | #initdim($self,getx($self->hdr),size=>$s(0),min=>sclr($pos_d(0)),inc=>sclr($inc_d(0)),unit=>'mm'); | ||||||||||||||||||||||||||||
| 469 | #initdim($self,gety($self->hdr),size=>$s(1),min=>sclr($pos_d(1)),inc=>sclr($inc_d(1)),unit=>'mm'); | ||||||||||||||||||||||||||||
| 470 | #} | ||||||||||||||||||||||||||||
| 471 | 0 | initdim($self,getz($self->hdr),size=>$s(2),min=>sclr($pos_d(2)),inc=>sclr($inc_d(2)),unit=>'mm',); | |||||||||||||||||||||||||||
| 472 | #say "initdim for x,y,z done."; | ||||||||||||||||||||||||||||
| 473 | #say "after init dim ",(diminfo ($self)); | ||||||||||||||||||||||||||||
| 474 | #say "size $s min $pos_d inc $inc_d rot $rot"; | ||||||||||||||||||||||||||||
| 475 | 0 | idx($self,'x',sclr dimsize($self,'x')/2); | |||||||||||||||||||||||||||
| 476 | 0 | idx($self,'y',sclr dimsize($self,'y')/2); | |||||||||||||||||||||||||||
| 477 | 0 | idx($self,'z',sclr dimsize($self,'z')/2); | |||||||||||||||||||||||||||
| 478 | 0 | say "Index x ",idx($self,'x'); | |||||||||||||||||||||||||||
| 479 | 0 | say "Dimsize ",dimsize($self); | |||||||||||||||||||||||||||
| 480 | # other dimensions | ||||||||||||||||||||||||||||
| 481 | 0 | for my $n (3..$#{$$opt{MRISiemens}->{Dimensions}}) { # x,y,z are handled above | |||||||||||||||||||||||||||
| 482 | 0 | my $dim=$$opt{MRISiemens}->{Dimensions}->[$n]; | |||||||||||||||||||||||||||
| 483 | 0 | print "Init Dim $dim - $n\n"; | |||||||||||||||||||||||||||
| 484 | 0 | my $str=('(0),' x ($n-2)).','.('(0),' x ($#{$$opt{Dimensions}}-$n)); | |||||||||||||||||||||||||||
| 485 | #say "$str "; | ||||||||||||||||||||||||||||
| 486 | # | ||||||||||||||||||||||||||||
| 487 | # WARNING !!! | ||||||||||||||||||||||||||||
| 488 | # Adding uniq to deal with multiple dimensions. THis may not be a good solution. | ||||||||||||||||||||||||||||
| 489 | # | ||||||||||||||||||||||||||||
| 490 | 0 | ▶ | if ($dim eq 'Echo') { | ||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||
| 491 | # my $str=('(0),' x ($n-2)).','.('(0),' x ($#{$$opt{Dimensions}}-$n)); | ||||||||||||||||||||||||||||
| 492 | 0 | initdim ($self,'echo',unit=>'ms', | |||||||||||||||||||||||||||
| 493 | vals=>[list (uniq hpar($self,'dicom','Echo Time')->($str))]); | ||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||
| 495 | elsif ($dim eq 'T') { | ||||||||||||||||||||||||||||
| 496 | # my $str=('(0),' x ($n-2)).','.('(0),' x ($#{$$opt{Dimensions}}-$n)); | ||||||||||||||||||||||||||||
| 497 | 0 | my $t=uniq hpar($self,'dicom','Acquisition Time')->($str); | |||||||||||||||||||||||||||
| 498 | 0 | ▶ | if (is_equidistant($t,0.003) && $t->nelem>1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
is_equidistant($t, "0.003") and $t->nelem > 1
MC/DC0%0/2
is_equidistant($t, "0.003") and $t->nelem > 1
is_equidistant($t, "0.003")
$t->nelem > 1
Truth table0%0/3
A and B
A= is_equidistant($t, "0.003")B= $t->nelem > 1
| |||||||||||||||||||||||||||||
| 499 | 0 | initdim ($self,'t',unit=>'s',min=>sclr($t(0)),max=>sclr($t(-1))); | |||||||||||||||||||||||||||
| 500 | #say "T min ",dmin($self,'t')," max ",dmax($self,'t')," inc ",dinc($self,'t'), $t; | ||||||||||||||||||||||||||||
| 501 | } else { | ||||||||||||||||||||||||||||
| 502 | 0 | initdim ($self,'t',unit=>'s',vals=>[list($t)]); | |||||||||||||||||||||||||||
| 503 | #say "T values :",vals ($self,'t'); | ||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||
| 505 | } elsif ($dim =~ /Channel/) { | ||||||||||||||||||||||||||||
| 506 | 0 | ▶ | my $coil=hpar($self,'dicom','0051,100f')||'combined'; | ||||||||||||||||||||||||||
|
Condition0%0/2
hpar($self, 'dicom', '0051,100f') || 'combined'
MC/DC0%0/1
hpar($self, 'dicom', '0051,100f') || 'combined'
hpar($self, 'dicom', '0051,100f')
Truth table0%0/2
A
A= hpar($self, 'dicom', '0051,100f')
| |||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if ($self->dim($n)>1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 508 | 0 | initdim ($self,'channel',vals=>[hpar($self,'dicom','0051,100f')->flat->(:2)]); | |||||||||||||||||||||||||||
| 509 | } else { | ||||||||||||||||||||||||||||
| 510 | 0 | initdim ($self,'channel',vals=>[$coil, size=>1]); | |||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||
| 512 | } elsif ($dim =~ /Set/) { | ||||||||||||||||||||||||||||
| 513 | 0 | initdim ($self,'set'); # This can be anything, no further info easily available | |||||||||||||||||||||||||||
| 514 | } elsif ($dim =~ /Phase/) { | ||||||||||||||||||||||||||||
| 515 | 0 | my $t=uniq hpar($self,'dicom','Trigger Time'); | |||||||||||||||||||||||||||
| 516 | #say $t->info; | ||||||||||||||||||||||||||||
| 517 | 0 | $t=$t($str); | |||||||||||||||||||||||||||
| 518 | #say $t; | ||||||||||||||||||||||||||||
| 519 | 0 | ▶ | if (is_equidistant($t)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 520 | 0 | initdim ($self,'cphase',unit=>'ms',min=>sclr($t(0)),max=>sclr($t(-1))); | |||||||||||||||||||||||||||
| 521 | #say "Trigger min ",dmin($self,'cphase')," max ",dmax($self,'cphase')," inc ",dinc($self,'cphase'), $t; | ||||||||||||||||||||||||||||
| 522 | #say "Trigger ",vals ($self,'cphase'); | ||||||||||||||||||||||||||||
| 523 | } else { | ||||||||||||||||||||||||||||
| 524 | 0 | initdim ($self,'cphase',unit=>'ms',vals=>[list($t)]); | |||||||||||||||||||||||||||
| 525 | #say "Trigger values :",vals ($self,'cphase'); | ||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||
| 529 | 0 | my $trot=stretcher(ones($self->ndims)); | |||||||||||||||||||||||||||
| 530 | 0 | $trot(:2,:2).=$srot; | |||||||||||||||||||||||||||
| 531 | 0 | drot($self,undef,undef,$trot); | |||||||||||||||||||||||||||
| 532 | 0 | my $mat=$trot x stretcher (pdl(dinc($self))); | |||||||||||||||||||||||||||
| 533 | 0 | $mat=$mat->transpose ;#if ($pe_dir =~ /COL/); | |||||||||||||||||||||||||||
| 534 | #say $mat; | ||||||||||||||||||||||||||||
| 535 | 0 | my $xf=t_linear(matrix=>$mat,post=>$pos_d(,0;-)); | |||||||||||||||||||||||||||
| 536 | #say "inc ",dinc ($self); | ||||||||||||||||||||||||||||
| 537 | ##say diminfo($self); | ||||||||||||||||||||||||||||
| 538 | 0 | hpar($self,'init_transform','matrix',$mat); | |||||||||||||||||||||||||||
| 539 | 0 | hpar($self,'init_transform','post',$pos_d(,0;-)); | |||||||||||||||||||||||||||
| 540 | #barf "initdim fails!" unless ($#{dimname($self)}>2); | ||||||||||||||||||||||||||||
| 541 | 0 | say "Index ",idx($self); | |||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | 0 | ▶ | sub getz { | ||||||||||||||||||||||||||
|
Subroutine
getz: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 546 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 547 | #return 'z'; | ||||||||||||||||||||||||||||
| 548 | #say "getz ",$self->{orientation}; | ||||||||||||||||||||||||||||
| 549 | 0 | ▶ | return 'z' if ($self->{orientation}=~/Tra/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 550 | 0 | ▶ | return 'x' if ($self->{orientation}=~/Sag/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 551 | 0 | return 'y' # if 'Cor' | |||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | 0 | ▶ | sub gety { | ||||||||||||||||||||||||||
|
Subroutine
gety: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 555 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 556 | #return 'y'; | ||||||||||||||||||||||||||||
| 557 | #say "gety ",$self->{orientation}; | ||||||||||||||||||||||||||||
| 558 | 0 | ▶ | return 'y' if ($self->{orientation}=~/Tra/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 559 | #return 'y' if ($self->{orientation}=~/Tra/); | ||||||||||||||||||||||||||||
| 560 | 0 | return 'z' # if 'Sag|Cor' | |||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | 0 | ▶ | sub getx { | ||||||||||||||||||||||||||
|
Subroutine
getx: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 564 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 565 | #return 'x'; | ||||||||||||||||||||||||||||
| 566 | #say "getx ",$self->{orientation}; | ||||||||||||||||||||||||||||
| 567 | 0 | ▶ | return 'x' if ($self->{orientation}=~/Tra|Cor/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 568 | 0 | return 'y' # if 'Sag' | |||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | =head1 Specific handling of Simenes MRI data | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | MRI: | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | Key 0029,1010 is the Siemens specific field that contains the ICE | ||||||||||||||||||||||||||||
| 578 | mini-headers with dimension information - and position in matrix | ||||||||||||||||||||||||||||
| 579 | 0029,1020 is deleted from the header, it is big, containing the whole | ||||||||||||||||||||||||||||
| 580 | protocol. They are now parsed into the csa header structure. The important | ||||||||||||||||||||||||||||
| 581 | part, the Siemens protocol ASCCONV part, is stored in the ascconv key, see | ||||||||||||||||||||||||||||
| 582 | read_text_hdr. | ||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | MRS: | ||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | In this case, 0029,1110 and 0029,1120 are the proprietary parts of the header. | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | =head2 create_data | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | Plugin-specific code to create the data structure, in patricular dimensions. | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | =head2 fill_data | ||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | fill the data structure from individual DICOM images (slices, echoes, phases ...). | ||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | =head2 getx, gety, getz | ||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | returns name of x .. z dimensions in scanner (or patient?) orientation. | ||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||
| 603 | =head2 handle_duplicates | ||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | What to do if two images with the same position in the stack arrive. Throws an | ||||||||||||||||||||||||||||
| 606 | error, atm. Should handle duplicate exports | ||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||
| 608 | =head2 init_dims | ||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||
| 610 | provides support for PDL::Dims. Useful in combination with PDL::IO::Sereal to | ||||||||||||||||||||||||||||
| 611 | have a fully qualified data set. | ||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||
| 613 | This will fail for vNav navigator scans where the ascconv protocol is missing. | ||||||||||||||||||||||||||||
| 614 | It could be copied from the last setter. | ||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | =head2 map_slicegroup | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | returns the number, size and first slice of the current slice group. | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | =head2 parser | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | plugin specific stuff to parse all the headers | ||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | =head2 populate_header | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | Here happens the vendor/modallity specific stuff like parsing private fields. | ||||||||||||||||||||||||||||
| 627 | It is required to return a position vector in the series' piddle. | ||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||
| 629 | =head2 read_csa | ||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||
| 631 | parses the 0029,XX10 or 20 fields containing Siemens CSA header information. | ||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||
| 633 | =head2 read_dcm | ||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||
| 635 | plugin specific stuff to read a DICOM file | ||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | =head2 read_text_hdr | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | parses the ASCCONV part of Siemens data header into the ascconv field of the | ||||||||||||||||||||||||||||
| 640 | piddle header. All special characters except [a-z0-9]i are converted to _ -- no | ||||||||||||||||||||||||||||
| 641 | quoting of hash keys required! You don't need to load this yourself. | ||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||
| 643 | This should handle setter/vNav, ascconv data is available from the target only, | ||||||||||||||||||||||||||||
| 644 | even though the series contains the navigator. Storing data from the last setter | ||||||||||||||||||||||||||||
| 645 | should be done somehow. | ||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | =head2 setup_dcm | ||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||
| 649 | sets useful options for this modality. | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | =head2 sort_protid | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | alternative to split based on lProtID (matches raw data key). To activate, | ||||||||||||||||||||||||||||
| 654 | after running setup_dcm, point option id to \&sort_protid. | ||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||
| 656 | =head1 Specific options | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | =over | ||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | =item Nifti | ||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | Do we want Nifti output? May be used by your plugin to apply additional steps, | ||||||||||||||||||||||||||||
| 663 | eg. more clumps, reorders, setting header fields ... | ||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||
| 665 | =item c_phase_t | ||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | Serialize phase and t dimensions | ||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||
| 669 | =back | ||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||
| 671 | =cut | ||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | 2 | 1; | |||||||||||||||||||||||||||