blib/lib/PDL/IO/Nifti.pm

filter: Statementstmt 17.1% 26 / 152 Branchbran 0.0% 0 / 60 Conditioncond 0.0% 0 / 40 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 38.4% 5 / 13 Podpod 100% 8 / 8 totaltotal 13.3% 39 / 292 CC 48 SCAR 45.7
CC
48
Cov
10%
read_nii
240.0
read_hdr
110.0
set_field
56.0
CRAP 96.6
↑ Summary
1 #!/usr/bin/env perl
2 #
3 package PDL::IO::Nifti;
4  
5  
6 2 ▶use base PDL;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use PDL;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use PDL::IO::FlexRaw;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 #use Getopt::Tabular;
10 #use Exporter;
11 #use Data::Dumper;
12 2 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 #@ISA = qw(Exporter);
14 #@EXPORT = qw(write_nii read_nii get_field set_field write_hdr read_hdr %template_nifti_header);
15 #@EXPORT = qw(write_nii read_nii);
16 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 #my $self;
19 2 my $template='ic10c18isCCs8fffssssf8fffsccffffiic80c24ssfffffff4f4f4c16c4'; #see nifti1.h
20  
21 2 my $byte_order='';
22 2 our $VERSION='0.73';
23 # define hash;
24 2 my %sizes=(
25 'c'=>1,
26 'C'=>1,
27 'l'=>4,
28 'S'=>2,
29 's'=>2,
30 'L'=>4,
31 'f'=>4,
32 'd'=>8,
33 'q'=>8,
34 'a'=>1,
35 'A'=>1,
36 );
37  
38 2 my $force=0;
39  
40 2 my %_map_pdltypes = ( # nifti datatype numbers of native pdl types
41 byte=>2, #'byte'=>2,
42 ushort=>256, #'ushort'=>256,
43 short=>4, #'short'=>4,
44 long=>8, #'long'=>8,
45 float=>16, #'float'=>16,
46 double=>64, #'double'=>64,
47 longlong=>1024, #'longlong'=>1024,
48 );
49  
50 2 my %_bitsize = ( # bits per pixel
51 0=>8, #'byte'=>2,
52 2=>16, #'ushort'=>256,
53 1=>16, #'short'=>4,
54 3=>32, #'long'=>8,
55 5=>32, #'float'=>16,
56 6=>64, #'double'=>64,
57 4=>64, #'longlong'=>1024,
58 );
59  
60  
61 2 my %_map_pdltypes_complex = ( # nifti datatype numbers of native complex (=pairs of) pdl types
62 5=>32,
63 6=>1792,
64 );
65 2 my %_maptypes = ( # [tyep,elements,needs conversion] ; conversion = 2 cannot be mapped losslessly
66 16=>['float',1,0,'f'],
67 32=>['float',2,0,'f'], # complex
68 64=>['double',1,0,'d'],
69 2=>['byte',1,0,'C'],
70 4=>['short',1,0,'s'],
71 8=>['long',1],
72 128=>['byte',3], # RGB
73 256=>['short',1,1,'s','c'], # signed char
74 512=>['ushort',1],
75 768=>['longlong',1,1,'q','L'], # unsigned long
76 1024=>['longlong',1],
77 1280=>['double',1,2,'d','Q'], # unsigned longlong
78 1536=>['double',1,2,'d','D'], # long double
79 1792=>['double',2], # complex double
80 2048=>['double',2,2,'d','D'], # complex long double
81 2304=>['byte',4], # RGBA
82 );
83 2 my @_farray;
84  
85  
86  
87 2 my %fields = ( # mapping NIFTI-1 usage, not ANALYZE
88 'sizeof_hdr' => {nr=>0,type=>'l',val=>348},
89 'data_type' => {nr=>1,type=>'c',length=>10, val=>''},
90 'db_name' => {nr=>2,type=>'c',length=>18, val=>''},
91 'extents' => {nr=>3,type=>'l',val=>0},
92 'session_error' => {nr=>4,type=>'s',val=>0},
93 'regular' => {nr=>5,type=>'c', val=>''},
94 'dim_info' => {nr=>6,type=>'c'},
95 'dim' => {nr=>7,type=>'s',count=>8},
96 'intent_p1' => {nr=>8,type=>'f'},
97 'intent_p2' => {nr=>9,type=>'f'},
98 'intent_p3' => {nr=>10,type=>'f'},
99 'intent_code' => {nr=>11,type=>'s',val=>'4001'},
100 'datatype' => {nr=>12,type=>'s'},
101 'bitpix' => {nr=>13,type=>'s'},
102 'slice_start' => {nr=>14,type=>'s',val=>0},
103 'pixdim' => {nr=>15,type=>'f',count=>8,
104 key=>['nifti_dims','x','y','z','t','te','chs',''],
105 val=>[8,1,1,1,1,1,1,1,1,],
106 },
107 'vox_offset' => {nr=>16,type=>'f',val=>352}, # start of image data
108 'scl_slope' => {nr=>17,type=>'f',val=>0},
109 'scl_inter' => {nr=>18,type=>'f',val=>0},
110 'slice_end' => {nr=>19,type=>'s',key=>'z'},
111 'slice_code' => {nr=>20,type=>'c'},
112 'xyzt_units' => {nr=>21,type=>'c',val=>10}, # 8 = sec, 2=mm
113 'cal_max' => {nr=>22,type=>'f'},
114 'cal_min' => {nr=>23,type=>'f'},
115 'slice_duration'=> {nr=>24,type=>'f'},
116 'toffset' => {nr=>25,type=>'f'},
117 'glmax' => {nr=>26,type=>'l'},
118 'glmin' => {nr=>27,type=>'l'},
119 'descrip' => {nr=>28,type=>'a',length=>80,
120 val=>'This is a file generated using PDL::IO::Nifti',
121 },
122 'aux_file' => {nr=>29,type=>'a',length=>24},
123 'qform_code' => {nr=>30,type=>'s',val=>0},
124 'sform_code' => {nr=>31,type=>'s',val=>0},
125 'quatern_b' => {nr=>32,type=>'f' },
126 'quatern_c' => {nr=>33,type=>'f' },
127 'quatern_d' => {nr=>34,type=>'f' },
128 'quatern_x' => {nr=>35,type=>'f' },
129 'quatern_y' => {nr=>36,type=>'f' },
130 'quatern_z' => {nr=>37,type=>'f' },
131 'srow_x' => {nr=>38,type=>'f',count=>4 ,val=>[0,0,0,0],},
132 'srow_y' => {nr=>39,type=>'f',count=>4,val=>[0,0,0,0,], },
133 'srow_z' => {nr=>40,type=>'f',count=>4 ,val=>[0,0,0,0,],},
134 'intent_name' => {nr=>41,type=>'a',length=>16 },
135 'magic' => {nr=>42,type=>'a',length=>4,val=>"n+1"},
136 'extension' => {nr=>43,type=>'c',count=>4,val=>[0,0,0,0],},
137 #'imag' => undef, # image data
138 );
139  
140 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
141 0 my $invocant=shift;
142 0 ▶ my $class = ref($invocant) || $invocant;
Condition0%0/3
ref $invocant || $invocant
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $invocant || $invocant
ref $invocant $invocant
Truth table0%0/3
A || B
A= ref $invocantB= $invocant
ABresult
1X1
011
000
143 0 my $self=\%fields;
144 0 bless $self,$class;
145 0 for my $field (sort (keys %$self)) {
146 # say "$field $self->{$field}";
147 0 ▶ next if ($field =~/PDL|force/); # list of special parameters.
Branch: 1 branch
BranchTrueFalseTotal
if $field =~ /PDL|force/ 0 0 0
148 0 $_farray[$$self{$field}->{nr}]=$field;
149 }
150 0 my $obj=shift;
151 #if ($obj) {
152 0 ▶ if (eval {$obj->isa('PDL')}) { # a piddle!
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { $obj->isa('PDL') } }) { } 0 0 0
elsif (-f $obj) { } 0 0 0
153 0 print "assigning piddle \n";
154 0 $self->img($obj) ; # loads image into imag.
155 } elsif (-f $obj) { # a valid file name !
156 0 print "opening file $obj\n";
157 # open my $file,$obj or die "$obj cannot be read\n";
158 0 $self->read_nii($obj);
159 }
160 #}
161 #my $file=shift;
162 #$n_hdr{img}=pdl(null);
163 0 return $self;
164 }
165  
166 0 ▶sub set_field {
Subroutine set_field: not called CC=7 SCAR=40.3
Pod documented
167 0 my $self=shift;
168 0 my $field=shift;
169 0 my $val=shift; # either a scalar, or a arrayref when setting a list-like value.
170 0 my $count=shift; # index if list values are to be set
171 #say "() setting $field to $val! ($count)";
172 0 ▶ if ($$self{$field}->{count}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$field}{'count'}) { } 0 0 0
173 warn "This field $field has only ".$$self{$field}->{count}."elements!
174 Your assignment will be (partially) lost!"
175 0 ▶ if (($$self{$field}->{count}<=$count and $count) or ($$self{$field}->{count}<=$#{$val}));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$field}{"count"} <= $count and $count or $self->{$field}{"count"} <= $#{$val;} 0 0 0
Condition0%0/6
$self->{$field}{"count"} <= $count and $count or $self->{$field}{"count"} <= $#{$val;}
l!l&&r!l&&!r
000
$self->{$field}{"count"} <= $count and $count
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{$field}{"count"} <= $count and $count or $self->{$field}{"count"} <= $#{$val;}
$self->{$field}{"count"} <= $count $count $self->{$field}{"count"} <= $#{$val;}
Truth table0%0/5
A and B or C
A= $self->{$field}{"count"} <= $countB= $countC= $self->{$field}{"count"} <= $#{$val;}
ABCresult
11X1
0X11
1011
0X00
1000
176 0 ▶ if (defined $count) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $count) { } 0 0 0
177 0 $$self{$field}->{val}[$count]=$val;
178 } else {
179 0 $$self{$field}->{val}->[$$self{$field}->{count}]+=0;
180 0 $$self{$field}->{val}=$val; #
181 }
182 } else {
183 0 ▶ warn "This field $field has only ".$$self{$field}->{count}."elements! Your assignment will be (partially) lost!"
Branch: 1 branch
BranchTrueFalseTotal
if $count 0 0 0
184 if $count;
185 0 $$self{$field}->{val}=$val;
186 }
187 }
188  
189 0 ▶sub get_field { # sets a field in the header.
Subroutine get_field: not called CC=3 SCAR=24.8
Pod documented
190 0 my $self=shift;
191 0 my $field=shift;
192 0 ▶ return $self unless $field; # You wanted all of it!!!
Branch: 1 branch
BranchTrueFalseTotal
unless $field 0 0 0
193 #$field=$self->n_hdr{$field};
194 #print "fields used are ".@{keys %$self} unless defined $field;
195 #my $val=shift;
196 0 my $count=shift;
197 0 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) { } 0 0 0
198 0 return $$self{$field}->{val}[$count];
199 } else {
200 #say "$field: Array :",$self->{$field}->{val};
201 0 return $$self{$field}->{val}; # this can be a list if count>0!
202 }
203 }
204  
205 0 ▶sub img {
Subroutine img: not called CC=4 SCAR=30.0
Pod documented
206 0 my $self=shift;
207 0 my $pdl=shift;
208 0 ▶ if (eval {$pdl->nelem}) { # a piddle!
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $pdl->nelem } }) 0 0 0
209 0 ▶ barf "not a piddle" unless UNIVERSAL::isa($pdl, 'PDL');
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($pdl, "PDL") 0 0 0
210 #say "Data Type (pdl) ".$pdl->type;
211 0 $self->{PDL}=$pdl->copy;
212 #say "Data Type (pdl) ".$self->type;
213 0 $self->set_field ('datatype' , $_map_pdltypes{$self->type});
214 #say ("What's going on? ".$self->get_field ('datatype' ), $_map_pdltypes{$self->{PDL}->type});
215 0 $self->set_field ('bitpix' , $_bitsize{$self->{PDL}->type});
216 0 $self->set_field ('dim',[$self->{PDL}->ndims,$self->{PDL}->dims]);
217  
218 0 ▶ $self->barf ("could not set datatype for ".$pdl->info." (".$pdl->type." ".$self->get_field('datatype'))
Branch: 1 branch
BranchTrueFalseTotal
unless $self->get_field("datatype") 0 0 0
219 unless $self->get_field('datatype');
220 }
221 #say "Imag: ".($self->{imag}->info);
222 0 return $self->{PDL};
223 }
224  
225 0 ▶sub read_hdr {
Subroutine read_hdr: not called CC=10 SCAR=47.0
Pod documented
226 0 my $self=shift;
227 0 my $file=shift; # Ref to filehandle
228 0 binmode $file,':raw:';
229 0 my $str;
230 # determine byte order from dim[0] (max. 7)
231 0 seek $file,40,0;
232 0 my $o;
233 0 read $file,$o,2;
234 0 seek $file,0,0;
235 0 $o=unpack 's',$o;
236 0 ▶ die "No dimenison info $o" unless $o;
Branch: 1 branch
BranchTrueFalseTotal
unless $o 0 0 0
237 0 ▶ $byte_order='>' if ($o>8);
Branch: 1 branch
BranchTrueFalseTotal
if $o > 8 0 0 0
238 0 print "Dims: $o, byte order string: '$byte_order'\n";
239 #my %nifti=%template_nifti_header;
240 #read $file,$str,352;
241 0 my $pos=0;
242 0 for my $field (@_farray) {
243 #my $field=$_farray[$i];
244 0 ▶ my $c=int($$self{$field}->{count}||1)*($$self{$field}->{length}||1); # field counter in pack string
Condition0%0/4
$self->{$field}{'count'} || 1
l!l
00
$self->{$field}{'length'} || 1
l!l
00
MC/DC0%0/1
$self->{$field}{'count'} || 1
$self->{$field}{'count'}
MC/DC0%0/1
$self->{$field}{'length'} || 1
$self->{$field}{'length'}
Truth table0%0/2
A
A= $self->{$field}{'count'}
Aresult
11
00
Truth table0%0/2
A
A= $self->{$field}{'length'}
Aresult
11
00
245 0 read $file,my $item,$sizes{$$self{$field}->{type}}*$c;
246 #say ($$self{$field}->{type});
247 0 ▶ next if ($$self{$field}->{type} eq '1');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$field}{"type"} eq 1 0 0 0
248 #say "$field ,".$$self{$field}->{type};# if ($$self{$field}->{type} eq '1');
249 0 ▶ if ($$self{$field}->{count}>1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$field}{'count'} > 1) { } 0 0 0
250 0 ▶ if ($$self{$field}->{type} =~ m/[sSlLqQfF]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$field}{'type'} =~ /[sSlLqQfF]/) { } 0 0 0
251 0 $self->set_field($field,[unpack ($$self{$field}->{type}.$byte_order.$c,$item)]) ;
252 #say $pos," Field $field size $c: $item: ",unpack($self->{$field}->{type}.$c,$item)," ",$self->get_field($field);
253 } else {
254 0 $self->set_field($field,[unpack ($$self{$field}->{type}.$c,$item)]) ;
255 }
256 } else {
257 0 ▶ if ($$self{$field}->{type} =~ m/[sSlLqQfF]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$field}{'type'} =~ /[sSlLqQfF]/) { } 0 0 0
258 0 $self->set_field($field,unpack ($$self{$field}->{type}.$byte_order.$c,$item));
259 #say $pos," Field $field size $c: $item: ",unpack($self->{$field}->{type}.$c,$item)," ",$self->get_field($field);
260 } else {
261 0 $self->set_field($field,unpack ($$self{$field}->{type}.$c,$item)) ;
262 }
263 }
264 0 $pos+=$c*$sizes{$$self{$field}->{type}};
265
266 }
267 #say $pos;
268 #say "Dim, ",@{$self->get_field('dim')};
269 #say "magic, ",$self->get_field('magic');
270 #say "dim ",@{$self->get_field('dim')};
271 #say Dumper $self;
272 #return \%nifti;
273 }
274  
275 0 ▶sub write_hdr {
Subroutine write_hdr: not called CC=6 SCAR=37.4
Pod documented
276 0 my $self=shift;
277 0 my $file=shift; # ref to filehandle
278 #my %nii=%{shift()};
279 0 my $pstring;
280 0 for my $field (@_farray) {
281 0 ▶ next unless $field;
Branch: 1 branch
BranchTrueFalseTotal
unless $field 0 0 0
282 #next if ($field eq 'imag');
283 #say "Field "%{$field};
284 #say "$field , ",$self->get_field($field) ;#->{$field}->{type};
285 0 ▶ my $c=int($$self{$field}->{count}||$$self{$field}->{length}||1); # field counter in pack string
Condition0%0/5
$self->{$field}{'count'} || $self->{$field}{'length'} || 1
l!l
00
$self->{$field}{"count"} or $self->{$field}{"length"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{$field}{'count'} || $self->{$field}{'length'} || 1
$self->{$field}{"count"} $self->{$field}{"length"}
Truth table0%0/3
A or B
A= $self->{$field}{"count"}B= $self->{$field}{"length"}
ABresult
1X1
011
000
286 #say unpack 'a4',pack ($$self{$field}->{type}.$c,$$self{$field}->{val}) if ($field eq 'magic');
287 #say unpack 'a4',pack 'a4','n+1';
288 0 ▶ unless ( $$self{$field}->{count} > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$field}{'count'} > 1) { } 0 0 0
289 0 $pstring.=pack ( $$self{$field}->{type}.$c,$$self{$field}->{val});
290 } else {
291 0 $pstring.=pack ( $$self{$field}->{type}.$c,@{$$self{$field}->{val}});
292 }
293 }
294 #say "dims: ",@{$self->get_field('dim')};
295 0 print $file $pstring;
296 }
297  
298 0 ▶sub write_nii {
Subroutine write_nii: not called CC=4 SCAR=30.0
Pod documented
299 0 my $self=shift;
300 0 my $f=shift; # ref to filehandle
301 #my $img=shift; # piddle
302 #my %hdr=shift; # prepared nifti header
303 #print "file exists $f" if (-f $f);
304 0 my $file;
305 #if (-f $f) {
306 0 ▶ fileno $f && ($file=$f) || (open $file,">$f" or die "Could not open $f for write\n") ; #unless ref($file);
Branch: 1 branch
BranchTrueFalseTotal
fileno $f and $file = $f or (open $file, ">$f" or die "Could not open $f for write\n") 0 0 0
Condition0%0/8
fileno $f && ($file = $f) || (open($file, ">$f") || die("Could not open $f for write\n"))
l!l&&r!l&&!r
000
fileno $f and $file = $f
!ll&&!rl&&r
000
open $file, ">$f" or die "Could not open $f for write\n"
l!l
00
MC/DC0%0/3
fileno $f && ($file = $f) || (open($file, ">$f") || die("Could not open $f for write\n"))
fileno $f $file = $f open $file, ">$f"
Truth table0%0/5
A and B || C
A= fileno $fB= $file = $fC= open $file, ">$f"
ABCresult
11X1
0X11
1011
0X00
1000
307 #print "opening $file\n";
308 #} else {
309 # $file=$f;
310 #}
311 0 binmode $file ,':raw:';
312 0 truncate $file,0;
313 0 seek $file,0,0;
314 #say "Curr. pos.: ",tell($file);
315 #my $file=*FH;
316 #say "Dim, ",@{$self->get_field('dim')};
317 #say "magic, ",$self->get_field('magic');
318 #say Dumper( $self);
319 #say $self->{imag}->info;
320 0 $self->write_hdr($file);
321 0 seek ($file,$self->get_field('vox_offset'),0);
322 #say "Curr. pos.: ",tell($file);
323 #my $d=Data::Dumper->new (
324 0 writeflex ($file,$self);#->img);
325 #say ("Writeflex: ".$d->Dump);
326 #say "Curr. pos.: ",tell($file);
327 #print "bla\n";
328 0 close $file;
329 #return \%hdr; # returns header
330 }
331  
332 0 ▶sub read_nii {
Subroutine read_nii: not called CC=15 SCAR=54.8
Pod documented
333 0 my $self=shift;
334 0 my $f=shift; # ref to filehandle
335 0 my $file;
336 #print "reading file\n";
337 0 ▶ fileno $f && ($file=$f) || ((open ($file,$f) ||die "Could not open $file\n")) ;
Branch: 1 branch
BranchTrueFalseTotal
fileno $f and $file = $f or (open $file, $f or die "Could not open $file\n") 0 0 0
Condition0%0/8
fileno $f && ($file = $f) || (open($file, $f) || die("Could not open $file\n"))
l!l&&r!l&&!r
000
fileno $f and $file = $f
!ll&&!rl&&r
000
open $file, $f or die "Could not open $file\n"
l!l
00
MC/DC0%0/3
fileno $f && ($file = $f) || (open($file, $f) || die("Could not open $file\n"))
fileno $f $file = $f open $file, $f
Truth table0%0/5
A and B || C
A= fileno $fB= $file = $fC= open $file, $f
ABCresult
11X1
0X11
1011
0X00
1000
338 0 binmode $file,':raw:';
339 0 $self->read_hdr ($file); # fill header
340 0 seek ($file, min (pdl($self->get_field('vox_offset')),352),0);
341 0 my $dims=$self->get_field('dim');
342 #say "$dims, @$dims";
343 0 my $ndims=shift @{$dims};
344 #say "Dims @$dims";
345 #say $self->get_field('datatype');
346 0 my ($type,$i,$j,$k,$l)=@{$_maptypes{$self->get_field('datatype')}};
347 #say "$type,$i,$j,$k,$l";
348 0 ▶ while (!$$dims[-1]) {pop @$dims;} # Remove trailing 0s to avoid 0-length dim in piddle
Branch: 1 branch
BranchTrueFalseTotal
unless ($dims->[-1]) 0 0 0
349 0 ▶ unshift @$dims,$i if ($i>1); # First dim is now complex or RGB if required.
Branch: 1 branch
BranchTrueFalseTotal
if $i > 1 0 0 0
350
351 0 ▶ unless ($j) { # type is native, no conversion necessary
Branch: 2 branches
BranchTrueFalseTotal
if ($j) { } 0 0 0
if (do { $j >= 1 }) 0 0 0
352 #say "Reading data now $type, $ndims, @$dims";
353 0 ▶ if ($byte_order) {
Branch: 1 branch
BranchTrueFalseTotal
if ($byte_order) { } 0 0 0
354 0 $self->img(readflex ($file,[{Type=>'swap'},{Type=>$type,Dims=>$dims}]));
355 } else {
356 0 $self->img(readflex ($file,[{Type=>$type,Dims=>$dims}]));
357 }
358 0 } elsif ($j>=1) { # a remapping is necessary
359 #print "We convert now ! ",$self->get_field('datatype')."\n";
360 0 ▶ die "This conversion is not possible without data loss\n" if ($j==2 and !$$self{force});
Branch: 1 branch
BranchTrueFalseTotal
if $j == 2 and not $self->{"force"} 0 0 0
Condition0%0/3
$j == 2 and not $self->{"force"}
!ll&&!rl&&r
000
MC/DC0%0/2
$j == 2 and not $self->{"force"}
$j == 2 not $self->{"force"}
Truth table0%0/3
A and not(B)
A= $j == 2B= not $self->{"force"}
ABresult
0X0
100
111
361 0 my $d=pdl(@$dims);
362 0 my $buf=max $d; # Buffer
363 0 my $its=prod $d/$buf; # iterations
364 0 my $str;
365 0 $d=zeroes($type,$d);
366 0 my $repacked=$d->get_dataref;
367 0 ▶ die "Conversion from $l to $k not possible " unless ($k and $l);
Branch: 1 branch
BranchTrueFalseTotal
unless $k and $l 0 0 0
Condition0%0/3
$k and $l
!ll&&!rl&&r
000
MC/DC0%0/2
$k and $l
$k $l
Truth table0%0/3
A and B
A= $kB= $l
ABresult
0X0
100
111
368 0 for my $n (0..$its-1) {
369 0 ▶ read $file,$str,$buf or die "Could not read from $file $!\n";
Branch: 1 branch
BranchTrueFalseTotal
read $file, $str, $buf or die "Could not read from $file $!\n" 0 0 0
370 0 $repacked.=pack($k.$buf,unpack($l.$byte_order.$buf,$str));
371 }
372 0 $d->upd_data;
373 0 $self->img($d);
374 # we need type mapping here, best done using inline C
375 }
376 }
377  
378 # maps hash to array for easier ordered IO, mainly
379  
380 #print "Array @_farray\n";
381 2 1;
382 __END__
↑ Summary