-
Notifications
You must be signed in to change notification settings - Fork 1
/
possum.tcl
3111 lines (2904 loc) · 136 KB
/
possum.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Possum - GUI for simulating FMRI
#
# Ivana Drobnjak and Mark Jenkinson, FMRIB Image Analysis Group
#
# Copyright (C) 2006-2007 University of Oxford
#
# Part of FSL - FMRIB's Software Library
# http://www.fmrib.ox.ac.uk/fsl
#
# Developed at FMRIB (Oxford Centre for Functional Magnetic Resonance
# Imaging of the Brain), Department of Clinical Neurology, Oxford
# University, Oxford, UK
#
#
# LICENCE
#
# FMRIB Software Library, Release 5.0 (c) 2012, The University of
# Oxford (the "Software")
#
# The Software remains the property of the University of Oxford ("the
# University").
#
# The Software is distributed "AS IS" under this Licence solely for
# non-commercial use in the hope that it will be useful, but in order
# that the University as a charitable foundation protects its assets for
# the benefit of its educational and research purposes, the University
# makes clear that no condition is made or to be implied, nor is any
# warranty given or to be implied, as to the accuracy of the Software,
# or that it will be suitable for any particular purpose or for use
# under any specific conditions. Furthermore, the University disclaims
# all responsibility for the use which is made of the Software. It
# further disclaims any liability for the outcomes arising from using
# the Software.
#
# The Licensee agrees to indemnify the University and hold the
# University harmless from and against any and all claims, damages and
# liabilities asserted by third parties (including claims for
# negligence) which arise directly or indirectly from the use of the
# Software or the sale of any products based on the Software.
#
# No part of the Software may be reproduced, modified, transmitted or
# transferred in any form or by any means, electronic or mechanical,
# without the express permission of the University. The permission of
# the University is not required if the said reproduction, modification,
# transmission or transference is done without financial return, the
# conditions of this Licence are imposed upon the receiver of the
# product, and all original and amended source code is included in any
# transmitted product. You may be held legally responsible for any
# copyright infringement that is caused or encouraged by your failure to
# abide by these terms and conditions.
#
# You are not permitted under this Licence to use this Software
# commercially. Use for which any financial return is received shall be
# defined as commercial use, and includes (1) integration of all or part
# of the source code or the Software into a product for sale or license
# by or on behalf of Licensee to third parties or (2) use of the
# Software or any derivative of it for research with the final aim of
# developing software products for sale or license to a third party or
# (3) use of the Software or any derivative of it for research with the
# final aim of developing non-software products for sale or license to a
# third party, or (4) use of the Software to provide any service to an
# external organisation for which payment is received. If you are
# interested in using the Software commercially, please contact Oxford
# University Innovation ("OUI"), the technology transfer company of the
# University, to negotiate a licence. Contact details are:
# [email protected] quoting reference DE/9564.
source $FSLDIR/tcl/fslstart.tcl
set VARS(history) {}
# RE:POSSUMDIR
# For all the users POSSUMDIR will be empty and therefore automatically become FSLDIR
# For me POSSUMDIR is my FSLDEVDIR directory. This allows me to run POSSUM on the cluster
# without having to make it stable and wait for a day or find way to run my binaries.
# It just seemed the easiest way to get around this. It is in all POSSUM scripts so please
# leave it that way if possible.
if [ info exists env(POSSUMDIR) ] {
set POSSUMDIR $env(POSSUMDIR)
} else {
set POSSUMDIR $FSLDIR
}
# The following two lines are just for me. Erase for the stable version.
puts ""
puts "Possum is running from POSSUMDIR=$POSSUMDIR"
proc possum { w } {
global entries guivars FSLDIR PWD HOME
# ---- Set up Frames ----
toplevel $w
wm title $w "POSSUM"
wm iconname $w "Possum"
wm iconbitmap $w @${FSLDIR}/tcl/fmrib.xbm
# tixBalloon $w.bhelp
frame $w.f
NoteBook $w.nb -side top -bd 2 -tabpady {5 5} -arcradius 3
$w.nb insert 0 object -text "Object"
$w.nb insert 1 pulse -text "Pulse Sequence"
$w.nb insert 2 b0field -text "B0 Field"
$w.nb insert 3 motion -text "Motion"
$w.nb insert 4 activation -text "Activation"
$w.nb insert 5 noise -text "Noise"
$w.nb insert 6 output -text "Run POSSUM"
$w.nb raise object
#----- Object-------
set objectlf [$w.nb getframe object]
set entries($w,obvol) ${FSLDIR}/data/possum/brain.nii.gz
possum:updateOBprop $w ${FSLDIR}/data/possum/brain.nii.gz
frame $w.objim
FileEntry $w.obvol \
-textvariable entries($w,obvol) \
-filetypes IMAGE \
-label "Input Object " \
-title "Select" \
-width 40 \
-filedialog directory \
-command "possum:updateOBprop $w; possum:updatecomptime $w "
pack $w.obvol -in $objectlf -anchor w -padx 3 -pady 3
label $w.objim.label -image "" -text " "
#tejas-edit: change command to '' to get back original
button $w.objim.preview -text "Preview Image" -command "possum:previewimagedialog $w"
#tejas-end
#$w.objim.label
pack $w.objim.preview -in $w.objim -pady 10
pack $w.objim -in $objectlf -anchor w -padx 3 -pady 3
#-------- Pulse sequence -----------
set pulself [$w.nb getframe pulse]
# LabelFrame $w.pul -text "EPI" -font {Helvetica 11 bold}
# pack $w.pul -in $pulself -side top -anchor w -padx 3 -pady 3
# set up default values
set entries($w,te) 0.030
set entries($w,tr) 3
set entries($w,trslc) 0.12
set entries($w,autotrslc) 1
set entries($w,outsize_nx) 64
set entries($w,outsize_ny) 64
set entries($w,outsize_nz) 1
set entries($w,outsize_dx) 4.0
set entries($w,outsize_dy) 4.0
set entries($w,outsize_dz) 1.0
set entries($w,numvol) 1
set entries($w,gap) 0
set entries($w,bw) 100000
set entries($w,zstart) 70
set entries($w,readgrad) x
set entries($w,phencode) y
set entries($w,slcselect) z
set entries($w,plus) +
set entries($w,pluss) +
set entries($w,maxG) 0.055
set entries($w,riseT) 0.00022
set entries($w,slcprof) "$FSLDIR/data/possum/slcprof"
set entries($w,numproc) 1
set entries($w,segs) 10000
set entries($w,ctt) 0
set entries($w,comptime) 0
set entries($w,motion_yn) 0
set entries($w,motion_type) 0
set entries($w,userintmotfile) ""
set entries($w,pulsechecktest) 1
set entries($w,b0inh_yn) 0
set entries($w,b0inhtime_yn) 0
set entries($w,cover) 100
set entries($w,flipangle) 90
#tejas - 2.11.12
set entries($w,seqtype) "epi"
set entries($w,onlyCheck) 1
set entries($w,usephantomdims) 0
# set entries($w,rfavg_yn) 0
set entries($w,makeb0motion_yn) 0
set entries($w,custompulse_yn) 0
#tejas-end
set entries($w,slcsampfactor) 2
# calculate dependendent quantities from the defaults
possum:updateTRSLC $w
possum:updateFOV $w
possum:updateechosp $w
possum:updatecomptime $w
# set up the GUI widgets
frame $w.topopts
frame $w.pulseseq
array set temp [list a 1 b 2]
label $w.pulseseq.seqlab -text "Sequence type:" -width 15 -anchor w
optionMenu2 $w.pulseseq.seqopt entries($w,seqtype) -command "possum:settimings $w; possum:updateTRSLC $w; possum:updateTRSLC2 $w; possum:custompulse $w" "epi" "Echo Planar Imaging (EPI)" "se-epi" "Spin-Echo Planar Imaging (SE-EPI)" "ge" "Gradient Echo (GE)" "se" "Spin Echo (SE)" "custom" "Custom Pulse Sequence"
pack $w.pulseseq.seqlab $w.pulseseq.seqopt -in $w.pulseseq -side left -anchor w
frame $w.t
label $w.t.spc1 -text "" -width 0
LabelSpinBox $w.t.x -label " TE (s): " -width 8 \
-textvariable entries($w,te) -range {0.0 10000.0 0.001}
label $w.t.spc2 -text "" -width 0
LabelSpinBox $w.t.y -label " TR (s): " -width 8 \
-textvariable entries($w,tr) -range {0.0 10000.0 0.001} \
-command "$w.t.y.spin.e validate; possum:updateTRSLC $w" \
-modifycmd "possum:updateTRSLC $w"
pack $w.t.spc1 $w.t.x $w.t.spc2 $w.t.y -in $w.t -side left -anchor nw -padx 10 -pady 5
pack $w.pulseseq $w.t -in $w.topopts -side left -anchor nw
frame $w.defaultframe
frame $w.n
label $w.n.lab -text "Number of Voxels: " -width 15 -anchor w -justify left
LabelSpinBox $w.n.x -label " X " -width 6 \
-textvariable entries($w,outsize_nx) -range { 1 10000 1 } \
-command "$w.n.x.spin.e validate; possum:updateFOV $w; possum:updatecomptime $w; possum:updateechosp $w" \
-modifycmd "possum:updateFOV $w; possum:updatecomptime $w; possum:updateechosp $w"
LabelSpinBox $w.n.y -label " Y " -width 6 \
-textvariable entries($w,outsize_ny) -range { 1 10000 1 } \
-command "$w.n.y.spin.e validate; possum:updateFOV $w;possum:updatecomptime $w;possum:updateechosp $w" \
-modifycmd " possum:updateFOV $w;possum:updatecomptime $w;possum:updateechosp $w"
LabelSpinBox $w.n.z -label " Z " -width 6 \
-textvariable entries($w,outsize_nz) -range { 1 10000 1 } \
-command "$w.n.z.spin.e validate; possum:updateFOV $w;possum:updatecomptime $w;possum:updateechosp $w; possum:updateTRSLC $w" \
-modifycmd " possum:updateFOV $w;possum:updatecomptime $w;possum:updateechosp $w; possum:updateTRSLC $w; possum:updatemotion $w; pack forget $w.motprevimg"
label $w.n.spc1 -text " " -width 3
label $w.n.nvollab -text "Number of Volumes: " -width 22 -anchor w -justify left
LabelSpinBox $w.n.nvolx -label " " -width 6 \
-textvariable entries($w,numvol) -range { 1 10000 1 } \
-command "$w.n.nvolx.spin.e validate; possum:updatecomptime $w" \
-modifycmd "possum:updatecomptime $w; possum:updatemotion $w; pack forget $w.motprevimg"
# pack $w.n.lab $w.n.x $w.n.y $w.n.z -in $w.n -side left -anchor w -padx 3 -pady 3
pack $w.n.lab $w.n.x $w.n.y $w.n.z $w.n.spc1 $w.n.nvollab $w.n.nvolx -in $w.n -side left -anchor w -padx 3 -pady 3
frame $w.d
label $w.d.lab -text "Voxel Size (mm): " -width 15 -anchor w -justify left
LabelSpinBox $w.d.x -label " X " -width 6 \
-textvariable entries($w,outsize_dx) -range { 0.000001 10000.0 0.1 } \
-command "$w.d.x.spin.e validate; possum:updateFOV $w; possum:updatecomptime $w;possum:updateechosp $w" \
-modifycmd " possum:updateFOV $w; possum:updatecomptime $w;possum:updateechosp $w"
LabelSpinBox $w.d.y -label " Y " -width 6 \
-textvariable entries($w,outsize_dy) -range { 0.000001 10000.0 0.1 } \
-command "$w.d.y.spin.e validate; possum:updateFOV $w;possum:updatecomptime $w;possum:updateechosp $w" \
-modifycmd " possum:updateFOV $w; possum:updatecomptime $w;possum:updateechosp $w"
LabelSpinBox $w.d.z -label " Z " -width 6 \
-textvariable entries($w,outsize_dz) -range { 0.000001 10000.0 0.1 } \
-command "$w.d.z.spin.e validate; possum:updateFOV $w; possum:updatecomptime $w;possum:updateechosp $w" \
-modifycmd "possum:updateFOV $w; possum:updatecomptime $w;possum:updateechosp $w"
label $w.d.spc1 -text " " -width 3
label $w.d.fliplab -text "Flip angle (deg): " -width 22 -anchor w -justify left
LabelSpinBox $w.d.flipx -label " " -width 6 \
-textvariable entries($w,flipangle) -range { 0 180 0.1 }
pack $w.d.lab $w.d.x $w.d.y $w.d.z $w.d.spc1 $w.d.fliplab $w.d.flipx -in $w.d -side left -anchor w -padx 3 -pady 3
frame $w.fov
label $w.fov.lab -text "Field of view (mm): " -width 15 -anchor w -justify left
LabelSpinBox $w.fov.x -label " X " -width 6 \
-textvariable entries($w,fov_x) -range { 0.000001 10000.0 0.1 }\
-command "$w.fov.x.spin.e validate; possum:updateVSIZE $w; possum:updatecomptime $w;possum:updateechosp $w" \
-modifycmd "possum:updateVSIZE $w; possum:updatecomptime $w;possum:updateechosp $w"
LabelSpinBox $w.fov.y -label " Y " -width 6 \
-textvariable entries($w,fov_y) -range { 0.000001 10000.0 0.1 }\
-command "$w.fov.y.spin.e validate; possum:updateVSIZE $w; possum:updatecomptime $w;possum:updateechosp $w" \
-modifycmd "possum:updateVSIZE $w; possum:updatecomptime $w;possum:updateechosp $w"
LabelSpinBox $w.fov.z -label " Z " -width 6 \
-textvariable entries($w,fov_z) -range { 0.000001 10000.0 0.1 }\
-command "$w.fov.z.spin.e validate; possum:updateVSIZE $w; possum:updatecomptime $w;possum:updateechosp $w" \
-modifycmd "possum:updateVSIZE $w; possum:updatecomptime $w;possum:updateechosp $w"
label $w.fov.spc1 -text " " -width 3
label $w.fov.stslclab -text "Starting slice position (mm): " -width 22 -anchor w -justify left
LabelSpinBox $w.fov.stslcx -label " " -width 6 \
-textvariable entries($w,zstart) -range { 0.0 10000.0 1.0 }
pack $w.fov.lab $w.fov.x $w.fov.y $w.fov.z $w.fov.spc1 $w.fov.stslclab $w.fov.stslcx -in $w.fov -side left -anchor w -padx 3 -pady 3
frame $w.s
label $w.s.spc2 -text " " -width 3
button $w.s.pulsecheck -command "Possum:pulsecheck $w 1" -text "Consistency check" -width 15
label $w.s.spc3 -text " " -width 5
button $w.s.preview -text "Preview slice prescription" -command "possum:previewslices $w" -anchor w
label $w.s.spc4 -text " " -width 5
button $w.s.createpulse -text "Save Pulse Sequence" -command "possum:savepulsedialog $w" -anchor w
pack $w.s.spc2 $w.s.preview $w.s.spc3 $w.s.pulsecheck $w.s.spc4 -in $w.s -side left -anchor center -padx 3 -pady 3
pack $w.s.createpulse -in $w.s
collapsible frame $w.slp -title "Slice Prescription" -command "$w.nb compute_size; set dummy"
frame $w.sr
label $w.sr.lab -text "Read gradient: " -width 22 -anchor w -justify left
radiobutton $w.sr.x -text "X" -variable entries($w,readgrad) -value x -anchor w
radiobutton $w.sr.y -text "Y" -variable entries($w,readgrad) -value y -anchor w
radiobutton $w.sr.z -text "Z" -variable entries($w,readgrad) -value z -anchor w
$w.sr.x select
label $w.sr.spc1 -text " " -width 5
label $w.sr.dirlab -text "Slice acquisition order: " -width 20 -anchor w -justify left
radiobutton $w.sr.dirx -text "+" -variable entries($w,plus) -value + -anchor w
radiobutton $w.sr.diry -text "-" -variable entries($w,plus) -value - -anchor w
$w.sr.dirx select
pack $w.sr.lab $w.sr.x $w.sr.y $w.sr.z $w.sr.spc1 $w.sr.dirlab $w.sr.dirx $w.sr.diry -in $w.sr -side left -anchor w -padx 3 -pady 3
frame $w.sp
label $w.sp.lab -text "Phase encode gradient: " -width 22 -anchor w -justify left
radiobutton $w.sp.x -text "X" -variable entries($w,phencode) -value x -anchor w
radiobutton $w.sp.y -text "Y" -variable entries($w,phencode) -value y -anchor w
radiobutton $w.sp.z -text "Z" -variable entries($w,phencode) -value z -anchor w
$w.sp.y select
label $w.sp.spc2 -text " " -width 5
label $w.sp.phlab -text "k-space coverage (%):" -width 20 -anchor w -justify left
LabelSpinBox $w.sp.phx -label " " -width 6 \
-textvariable entries($w,cover) -range { 50 100 0.1 } \
-command "$w.ph.x.spin.e validate; possum:updatecomptime $w" \
-modifycmd "possum:updatecomptime $w"
pack $w.sp.lab $w.sp.x $w.sp.y $w.sp.z $w.sp.spc2 $w.sp.phlab $w.sp.phx -in $w.sp -side left -anchor w -padx 3 -pady 3
frame $w.ss
label $w.ss.lab -text "Slice select gradient: " -width 22 -anchor w -justify left
radiobutton $w.ss.x -text "X" -variable entries($w,slcselect) -value x -anchor w
radiobutton $w.ss.y -text "Y" -variable entries($w,slcselect) -value y -anchor w
radiobutton $w.ss.z -text "Z" -variable entries($w,slcselect) -value z -anchor w
$w.ss.z select
label $w.ss.spc3 -text " " -width 5
label $w.ss.gaplab -text "Gap between slices (mm):" -width 20 -anchor w -justify left
LabelSpinBox $w.ss.gapv -label " " -width 6 \
-textvariable entries($w,gap) -range { 0.0 100.0 0.001 } \
-command "$w.gap.v.spin.e validate; possum:updatecomptime $w" \
-modifycmd "possum:updatecomptime $w"
pack $w.ss.lab $w.ss.x $w.ss.y $w.ss.z $w.ss.spc3 $w.ss.gaplab $w.ss.gapv -in $w.ss -side left -anchor w -padx 3 -pady 3
frame $w.ssf
LabelSpinBox $w.ssf.fac -label " Object slice resampling factor: " -width 8 \
-textvariable entries($w,slcsampfactor) -range {1 100} -modifycmd "possum:updatecomptime $w"
pack $w.ssf.fac -in $w.ssf -side left -anchor w -padx 3 -pady 3
pack $w.sr $w.sp $w.ss $w.ssf -in $w.slp.b -anchor w -padx 3 -pady 3
collapsible frame $w.scan -title "Scanner properties" -command "$w.nb compute_size; set dummy"
frame $w.scanfr1
label $w.scanfr1.maxGlab -text "Maximal gradient strength (T/m):" -width 28 -anchor w
LabelSpinBox $w.scanfr1.maxGv -label " " -width 10 \
-textvariable entries($w,maxG) -range { 0.0 100.0 0.001 }
label $w.scanfr1.spc1 -text " " -width 10
label $w.scanfr1.riseTlab -text "Rise time (s): " -width 15 -anchor w
LabelSpinBox $w.scanfr1.riseTv -width 10 -label " " \
-textvariable entries($w,riseT) -range { 0.0 100.0 0.00001 }
pack $w.scanfr1.maxGlab $w.scanfr1.maxGv $w.scanfr1.spc1 $w.scanfr1.riseTlab $w.scanfr1.riseTv -in $w.scanfr1 -side left -anchor w -pady 3
frame $w.bw
label $w.bw.lab -text "BW (Hz): " -width 28 -anchor w
LabelSpinBox $w.bw.x -width 10 -label " " \
-textvariable entries($w,bw) -range { 0 1000000 10 }\
-command "$w.bw.x.spin.e validate; possum:updateechosp $w" \
-modifycmd "possum:updateechosp $w"
label $w.bw.spc1 -text " " -width 10
label $w.bw.echolab -text "Echo spacing (s): " -width 15 -anchor w
label $w.bw.echox -textvariable entries($w,echosp) -width 10
#-readonlybackground white -state readonly
pack $w.bw.lab $w.bw.x $w.bw.spc1 $w.bw.echolab $w.bw.echox -in $w.bw -anchor e -side left
frame $w.slcprof
label $w.slcprof.lab -text "Slice profile " -width 10 -anchor w
FileEntry $w.slcprof.dir \
-textvariable entries($w,slcprof) \
-title "Select" \
-width 40 \
-filedialog directory
label $w.slcprof.spc1 -text "" -width 2
button $w.slcprof.prevslcbutton -command "possum:slcprofpreviewdialog $w" \
-text "Preview Slice Profile" -width 15
pack $w.slcprof.lab $w.slcprof.dir $w.slcprof.spc1 $w.slcprof.prevslcbutton -in $w.slcprof -anchor e -side left -pady 3
frame $w.trs
#checkbutton $w.trs.rfavg -text "RF Averaging" -variable entries($w,rfavg_yn) -padx 5 -justify center
#label $w.trs.spc1 -text "" -width 2
label $w.trs.lab -text "TRslice (s):" -width 10 -anchor w
LabelSpinBox $w.trs.z -label " " -width 8 \
-textvariable entries($w,trslc) -range {0.0 10000.0 0.001} -disabledbackground gray
checkbutton $w.trs.yn -text "Autoset" -variable entries($w,autotrslc) -command "possum:buttonTRSLC $w" -padx 5
possum:buttonTRSLC $w
#pack $w.trs.rfavg $w.trs.spc1 $w.trs.lab $w.trs.z $w.trs.yn -in $w.trs -side left -pady 3
pack $w.trs.lab $w.trs.z $w.trs.yn -in $w.trs -side left -pady 3
pack $w.scanfr1 $w.bw $w.slcprof $w.trs -in $w.scan.b -anchor w -padx 3 -pady 3 -expand yes -anchor nw
pack $w.n $w.d $w.fov $w.s $w.slp $w.scan -in $w.defaultframe -anchor nw -padx 3 -pady 3
pack $w.topopts $w.defaultframe -in $pulself -anchor nw -side top -padx 3 -pady 3
## Frame for custom pulse sequence
frame $w.custompulse
frame $w.inpulse
label $w.inpulse.lab -text "Pulse-sequence: " -width 15 -justify left -anchor w
FileEntry $w.inpulse.dir \
-textvariable entries($w,cuspulse) \
-title "Custom Pulse-Sequence" \
-width 40 \
-filedialog directory \
-command "possum:checkloadedpulse $w"
frame $w.customwarn
label $w.customwarn.lab -text "" -font { Helvetica 10 italic }
##
pack $w.inpulse.lab $w.inpulse.dir -in $w.inpulse -side left -anchor w -pady 3
collapsible frame $w.cusadv -title "Scanner Properties" -command "set dummy"
# checkbutton $w.rfavg -text "RF Averaging" -variable entries($w,rfavg_yn) -padx 5 -justify center
frame $w.slcprofcus
label $w.slcprofcus.lab -text " Slice profile " -width 12 -anchor w
FileEntry $w.slcprofcus.dir \
-textvariable entries($w,slcprof) \
-title "Select" \
-width 40 \
-filedialog directory
label $w.slcprofcus.spc1 -text "" -width 2
button $w.slcprofcus.prevslcbutton -command "possum:slcprofpreviewdialog $w" \
-text "Preview Slice Profile" -width 15
pack $w.slcprofcus.lab $w.slcprofcus.dir $w.slcprofcus.spc1 $w.slcprofcus.prevslcbutton -in $w.slcprofcus -anchor w -side left -pady 3
# pack $w.slcprofcus $w.rfavg -in $w.cusadv.b -anchor w -padx 3 -pady 3
pack $w.slcprofcus -in $w.cusadv.b -anchor w -padx 3 -pady 3
pack $w.inpulse $w.customwarn $w.cusadv -in $w.custompulse -anchor w -side top -padx 3 -pady 3
# -------- B0ield -------------
set guivars($w,lfb0field) [$w.nb getframe b0field]
#Field strength
set entries($w,b0strength) 1
possum:updateb0field $w
frame $w.b0test
LabelSpinBox $w.b0test.b0spin -width 8 \
-textvariable entries($w,b0fieldstrength) -range { 0.0 1000000.0 0.1 } -disabledbackground gray
LabelFrame $w.b0test.b0fil -text "Field strength "
optionMenu2 $w.b0test.b0fil.menu entries($w,b0strength) -command "possum:updateb0field $w ; possum:updateMRpar $w ; possum:updateb0fieldinh $w ; possum:updateBASEname $w; possum:updateBASEnametime $w; pack forget $w.mrpar.prev; $w.nb compute_size " 0 "1.5 T" 1 "3 T" 2 "Custom field ( T )"
pack $w.b0test.b0fil.menu
pack $w.b0test.b0fil -in $w.b0test
pack $w.b0test -in $guivars($w,lfb0field) -side top -anchor w -padx 3 -pady 3
#-------------------B0Field------------------------#
# MR par
frame $w.mrpar
frame $w.mrparopts
set entries($w,mrpar) "${FSLDIR}/data/possum/MRpar_3T"
FileEntry $w.mrparopts.dir \
-textvariable entries($w,mrpar) \
-label "MR parameters: " \
-title "Select" \
-width 40 \
-filedialog directory \
-command "pack forget $w.mrpar.prev"
label $w.mrparopts.spc1 -text "" -width 3
button $w.mrparopts.view -command "possum:showMRpar $w" -text "View MRpar File" -width 22
pack $w.mrparopts.dir $w.mrparopts.spc1 $w.mrparopts.view -in $w.mrparopts -anchor w -side left -padx 3 -pady 3
frame $w.mrpar.prev -relief raised -borderwidth 1
label $w.mrpar.prev.contents1 -text "" -justify center
label $w.mrpar.prev.contents2 -text "" -justify center
label $w.mrpar.prev.contents3 -text "" -justify center
label $w.mrpar.prev.contents4 -text "" -justify center
pack $w.mrpar.prev.contents1 $w.mrpar.prev.contents2 $w.mrpar.prev.contents3 $w.mrpar.prev.contents4 -in $w.mrpar.prev -anchor w -side left -padx 5 -pady 3
pack $w.mrparopts -in $w.mrpar -pady 3 -anchor w -side top
pack $w.mrpar -in $guivars($w,lfb0field) -anchor w -padx 3 -pady 3
#B0 field inhomogeneities
frame $w.b0main
frame $w.b0mainopts
set entries($w,b0f) "${FSLDIR}/data/possum/b0_ppm.nii.gz"
possum:updateB0prop $w $entries($w,b0f)
FileEntry $w.b0mainopts.dir \
-textvariable entries($w,b0f) \
-label "File name: " \
-filetypes IMAGE \
-title "Select" \
-width 40 \
-filedialog directory \
-command "possum:updateB0prop $w; possum:updatecomptime $w "
label $w.b0mainopts.spc1 -text "" -width 3
button $w.b0mainopts.preview -text "Preview Image" -command "possum:previewb0dialog $w" -width 22
pack $w.b0mainopts.dir $w.b0mainopts.spc1 $w.b0mainopts.preview -in $w.b0mainopts -anchor w -side left -padx 3 -pady 3
frame $w.b0main.b0u
radiobutton $w.b0main.b0u.ppm -text "ppm" -variable entries($w,b0units) -value ppm -anchor w
radiobutton $w.b0main.b0u.tesla -text "Tesla" -variable entries($w,b0units) -value tesla -anchor w
$w.b0main.b0u.ppm select
label $w.b0main.b0u.unit -text "Units (for file): "
pack $w.b0main.b0u.unit $w.b0main.b0u.ppm $w.b0main.b0u.tesla -anchor w -side left
## Widgets for standard B0 files
LabelFrame $w.b0main.b0fi -text "B0 field inhomogeneities (at 1 Tesla) "
optionMenu2 $w.b0main.b0fi.menu entries($w,b0inh_yn) -command "possum:updateb0fieldinh $w; possum:updateBASEname $w ; possum:updatecomptime $w; $w.nb compute_size" 0 "None" 1 "Custom file"
pack $w.b0main.b0fi.menu
pack $w.b0main.b0fi -in $w.b0main -side top -anchor w -padx 3 -pady 3
pack $w.b0main -in $guivars($w,lfb0field) -side top -anchor w -padx 3 -pady 3
#B0 inhomogeneities changing in time
frame $w.b0maintime
frame $w.b0timecourse
set entries($w,b0ftimecourse) "${FSLDIR}/data/possum/b0timecourse"
FileEntry $w.b0timecourse.dir \
-textvariable entries($w,b0ftimecourse) \
-label "B0 time course: " \
-title "Select" \
-width 40 \
-filedialog directory
label $w.b0timecourse.spc1 -text "" -width 3
button $w.b0timecourse.prev -text "Preview B0 Timecourse" -width 22 -command "possum:previewb0timecoursedialog $w"
pack $w.b0timecourse.dir $w.b0timecourse.spc1 $w.b0timecourse.prev -in $w.b0timecourse -anchor w -side left -padx 3 -pady 3
frame $w.b0timeimage
set entries($w,b0ftime) "${FSLDIR}/data/possum/b0extra.nii.gz"
possum:updateB0timeprop $w $entries($w,b0ftime)
FileEntry $w.b0timeimage.dir \
-textvariable entries($w,b0ftime) \
-label "B0 spatial modulation: " \
-filetypes IMAGE \
-title "Select" \
-width 40 \
-filedialog directory \
-command "possum:updateB0timeprop $w; possum:updatecomptime $w "
label $w.b0timeimage.spc1 -text "" -width 3
button $w.b0timeimage.prev -text "Preview B0 Spatial Modulation" -width 22 -command "possum:previewb0timedialog $w"
pack $w.b0timeimage.dir $w.b0timeimage.spc1 $w.b0timeimage.prev -in $w.b0timeimage -anchor w -side left -padx 3 -pady 3
############# NOT USED CURRENTLY ###############
FileEntry $w.b0maintime.b0f \
-textvariable entries($w,b0ftime) \
-label "B0 spatial modulation: " \
-filetypes IMAGE \
-title "Select" \
-width 40 \
-filedialog directory \
-command "possum:updateB0timeprop $w; possum:updatecomptime $w "
FileEntry $w.b0maintime.b0ftime \
-textvariable entries($w,b0ftimecourse) \
-label "B0 time course: " \
-title "Select" \
-width 40 \
-filedialog directory \
frame $w.b0maintime.b0im
label $w.b0maintime.b0im.label -image "" -text " "
button $w.b0maintime.b0im.preview -text "Preview Image" -command "possum:previewb0timedialog $w"
label $w.b0maintime.b0im.b0timewarn -text "" -font { Helvetica 9 italic } -height 2 -justify left -foreground red
########################################################
frame $w.b0maintime.b0u
set entries($w,b0unitstime) tesla
radiobutton $w.b0maintime.b0u.ppm -text "ppm" -variable entries($w,b0unitstime) -value ppm -anchor w
radiobutton $w.b0maintime.b0u.tesla -text "Tesla" -variable entries($w,b0unitstime) -value tesla -anchor w
label $w.b0maintime.b0u.unit -text "Units (for file): "
pack $w.b0maintime.b0u.unit $w.b0maintime.b0u.ppm $w.b0maintime.b0u.tesla -anchor w -side left
LabelFrame $w.b0maintime.b0fi -text "B0 field inhomogeneities (changing in time) "
optionMenu2 $w.b0maintime.b0fi.menu entries($w,b0inhtime_yn) -command "possum:updateb0fieldinhtime $w; possum:updateBASEnametime $w ; possum:updatecomptime $w ; possum:updatemotion $w; $w.nb compute_size" 0 "None" 1 "Custom file"
pack $w.b0maintime.b0fi.menu
pack $w.b0maintime.b0fi -in $w.b0maintime -side top -anchor w -padx 3 -pady 3
pack $w.b0maintime -in $guivars($w,lfb0field) -side top -anchor w -padx 3 -pady 3
# --------Motion-------------
set guivars($w,lfmotion) [$w.nb getframe motion]
set entries($w,mot) "${FSLDIR}/data/possum/motionRzLarge_0.12s"
FileEntry $w.mot \
-textvariable entries($w,mot) \
-label "Motion file " \
-title "Select" \
-width 40 \
-filedialog directory \
-command "possum:updatemotion $w ; pack forget $w.motprevimg"
button $w.motpreview -text "Preview Motion Plot" -command "possum:previewmotionplot $w"
label $w.motwarn -text "" -font { Helvetica 9 italic } -height 2 -justify left -foreground red
LabelFrame $w.moti -text ""
optionMenu2 $w.moti.menu entries($w,motion_yn) -command "possum:updatemotion $w; possum:updateb0fieldinhtime $w ; possum:updatecomptime $w; $w.nb compute_size " 0 "None" 1 "Custom file"
optionMenu2 $w.mottypemenu entries($w,motion_type) -command "possum:updatemotion $w ; possum:previewmotionplot $w ; pack forget $w.motprevimg" 0 "Continuous" 1 "Between slice" 2 "Between volumes"
label $w.motprevimg -text ""
pack $w.moti.menu
pack $w.moti -in $guivars($w,lfmotion) -side top -anchor w -padx 3 -pady 3
# --------Activation-------------
set guivars($w,lfactivation) [$w.nb getframe activation]
set entries($w,activ_yn) 0
set entries($w,act1) "$FSLDIR/data/possum/activation3D.nii.gz"
possum:updateACTprop $w $entries($w,act1)
set entries($w,act2) "$FSLDIR/data/possum/activation3Dtimecourse"
LabelFrame $w.activ -text ""
optionMenu2 $w.activ.menu entries($w,activ_yn) -command "possum:updateactivation $w" 0 "None" 1 "Custom file"
pack $w.activ.menu
pack $w.activ -in $guivars($w,lfactivation) -side top -anchor w -padx 3 -pady 3
frame $w.activation
frame $w.actt2timecourse
FileEntry $w.act1 \
-textvariable entries($w,act2) \
-label "T2* time course " \
-title "Select" \
-width 40 \
-filedialog directory
label $w.act1spc -text "" -width 3
button $w.act1prev -command "possum:previewt2startimecoursedialog $w" -text "Preview T2* time course" -width 25
pack $w.act1 $w.act1spc $w.act1prev -in $w.actt2timecourse -anchor w -side left -padx 3 -pady 3
frame $w.spatialmod
FileEntry $w.act2 \
-textvariable entries($w,act1) \
-filetypes IMAGE \
-label "T2* spatial modulation " \
-title "Select" \
-width 40 \
-filedialog directory \
-command "possum:updateACTprop $w"
label $w.act2spc -text "" -width 3
button $w.act2prev -command "possum:previewactivdialog $w" -text "Preview T2* spatial modulation" -width 25
pack $w.act2 $w.act2spc $w.act2prev -in $w.spatialmod -anchor w -side left -padx 3 -pady 3
pack $w.actt2timecourse $w.spatialmod -in $w.activation
# ------ Noise--------------------
set guivars($w,lfnoise) [$w.nb getframe noise]
set entries($w,noise_yn) 0
set entries($w,noisesnr) 10
set entries($w,noisesigma) 0
frame $w.noiseval
frame $w.noiseval1
frame $w.noiseval2
LabelSpinBox $w.noiseval1.snr -label "" -width 8 \
-textvariable entries($w,noisesnr) -range { 0.0 1000000.0 0.5 } -disabledbackground gray
LabelSpinBox $w.noiseval2.sigma -label "" -width 8 \
-textvariable entries($w,noisesigma) -range { 0.0 100000000.0 0.1 } -disabledbackground gray
radiobutton $w.noiseval1.unitssnr \
-text "SNR (relative to median object intensity): " \
-variable entries($w,noiseunits) \
-value snr -anchor w \
-command "possum:updatenoiseunits $w " -width 35
radiobutton $w.noiseval2.unitssigma \
-text "Absolute intensity (std dev): " \
-variable entries($w,noiseunits) \
-value sigma -anchor w \
-command "possum:updatenoiseunits $w " -width 35
pack $w.noiseval1.unitssnr $w.noiseval1.snr \
-in $w.noiseval1 -side left -anchor w -padx 3 -pady 3
pack $w.noiseval2.unitssigma $w.noiseval2.sigma \
-in $w.noiseval2 -side left -anchor w -padx 3 -pady 3
pack $w.noiseval1 $w.noiseval2 -in $w.noiseval
$w.noiseval1.unitssnr select
$w.noiseval2.sigma configure -state disabled
LabelFrame $w.noise -text ""
optionMenu2 $w.noise.menu entries($w,noise_yn) -command "possum:updatenoise $w" 0 "None" 1 "Thermal (white) noise "
pack $w.noise.menu
pack $w.noise -in $guivars($w,lfnoise) -side top -anchor w -padx 3 -pady 3
#------Output---------------------
set outputlf [$w.nb getframe output]
set entries($w,out) "$PWD/simdir"
FileEntry $w.out \
-textvariable entries($w,out) \
-label "Output directory " \
-title "Select" \
-width 50 \
-filedialog directory
##tejas
#------Run---------------------
frame $w.run
label $w.run.procstext -text "Number of Processors:" -anchor w -justify left
LabelSpinBox $w.run.procsspin -label " " -textvariable entries($w,numproc) \
-range { 1 10000 1 } \
-command "$w.run.procsspin.spin.e validate; possum:updatecomptime $w" \
-modifycmd "possum:updatecomptime $w"
pack $w.run.procstext $w.run.procsspin -in $w.run -side left -anchor nw -padx 3 -pady 5
possum:updatecomptime $w
label $w.run.runtimetext -text "Predicted Run time:" -anchor w -justify left
entry $w.run.runtimeout -textvariable entries($w,comptime) -width 12 -readonlybackground white -state readonly
pack $w.run.runtimetext $w.run.runtimeout -in $w.run -side left -anchor nw -padx 3 -pady 5
# Collapsible frame for advanced options
collapsible frame $w.runadv -title "Advanced" -command "$w.nb compute_size; set dummy"
frame $w.runopts
label $w.runopts.segtext -text "Segment size:" -anchor w -justify left
LabelSpinBox $w.runopts.segspin -label " " -width 6 -textvariable entries($w,segs) \
-range { 1 1000000 1 } \
-command "$w.runopts.segspin.spin.e validate; possum:updatecomptime $w" \
-modifycmd "possum:updatecomptime $w"
# pack $w.runopts.segtext $w.runopts.segspin -in $w.runadv.b -side left -anchor w -padx 3 -pady 5
label $w.runopts.runtimeusrtext -text "Run time:" -anchor w -justify left
LabelSpinBox $w.runopts.runtimeusrspin -label " " \
-width 4 -textvariable entries($w,ctt) \
-range { 0 1000000 1 } \
-command "$w.runopts.runtimeusrspin.spin.e validate"
pack $w.runopts.segtext $w.runopts.segspin $w.runopts.runtimeusrtext $w.runopts.runtimeusrspin -in $w.runopts -anchor w -side left -anchor w -padx 3 -pady 5
# frame $w.theorygo
# button $w.theorygo.generate -command "Possum:generateTheoryVolumeWindow $w" \
# -text "Spin-Echo Contrast Images" -width 50
# label $w.theorygo.spc1 -text "" -width 20
# pack $w.theorygo.spc1 $w.theorygo.generate -in $w.theorygo -pady 5
frame $w.savescript
label $w.savescript.status -text "" -width 50 -foreground black
button $w.savescript.go -text "Save commands to script" -width 50 \
-command "possum:savescriptdialog $w"
pack $w.savescript.go -in $w.savescript -pady 5 -anchor w -side top
# pack $w.runopts $w.theorygo $w.savescript -in $w.runadv.b -anchor w
pack $w.runopts $w.savescript -in $w.runadv.b -anchor w
pack $w.out $w.run $w.runadv -in $outputlf -side top -anchor w -pady 3 -padx 5
##tejas-end
# Outside the nb part.
# ---- Pack all of the options ----
frame $w.f.opts
pack $w.nb -in $w.f.opts -side top
# pack $w.np $w.ct $w.advanced -in $w.f.opts -side left -padx 2
pack $w.f.opts -in $w.f -side left -padx 8 -pady 6 -expand yes -fill both
# ---- Button Frame ----
frame $w.btns
frame $w.btns.b -relief raised -borderwidth 1
button $w.btns.go -command "Possum:apply $w" \
-text "Go" -width 5
button $w.btns.makedir -command "Possum:makedir $w" \
-text "Make Directory" -width 10
button $w.btns.cancel -command "destroy $w" \
-text "Exit" -width 5
button $w.btns.save -command "feat_file:setup_dialog $w a a a [namespace current] *.fsf {Save Possum setup} {possum:write $w} {}" -text "Save"
button $w.btns.load -command "feat_file:setup_dialog $w a a a [namespace current] *.fsf {Load Possum setup} {possum:load $w} {}" -text "Load"
button $w.btns.help -command "FmribWebHelp file: ${FSLDIR}/doc/possum/index.html" \
-text "Help" -width 5
pack $w.btns.b -side bottom -fill x
pack $w.btns.go $w.btns.makedir $w.btns.save $w.btns.load $w.btns.cancel $w.btns.help -in $w.btns.b \
-side left -expand yes -padx 3 -pady 10 -fill y
pack $w.f $w.btns -expand yes -fill both
}
proc Possum:pulsecheck { w {onlyCheck 0} } {
global entries
set status [ possum:pulsecheck $w $entries($w,obvol) $entries($w,mrpar) $entries($w,seqtype) $entries($w,te) $entries($w,tr) $entries($w,trslc) $entries($w,outsize_nx) $entries($w,outsize_ny) $entries($w,outsize_nz) $entries($w,outsize_dx) $entries($w,outsize_dy) $entries($w,outsize_dz) $entries($w,fov_x) $entries($w,fov_y) $entries($w,fov_z) $entries($w,numvol) $entries($w,zstart) $entries($w,gap) $entries($w,bw) $entries($w,readgrad) $entries($w,phencode) $entries($w,slcselect) $entries($w,plus) $entries($w,maxG) $entries($w,riseT) $entries($w,b0f) $entries($w,userintmotfile) $entries($w,act1) $entries($w,act2) $entries($w,out) $entries($w,numproc) $entries($w,segs) $entries($w,slcprof) $entries($w,cover) $entries($w,flipangle) $onlyCheck]
update idletasks
}
proc Possum:apply { w } {
global entries FSLDIR
set $entries($w,onlyCheck) 0
# start by saving the fsf file (with all variables as they are now)
#if { ! [ file isdirectory $entries($w,out) ] } {
#catch { exec sh -c "mkdir $entries($w,out)" } oval
#}
if { $entries($w,obvol) == "" } {
puts "The input object not specified."
return
}
if { $entries($w,mrpar) == "" } {
puts "The input MR parameters not specified."
return
}
if { $entries($w,slcprof) == "" } {
puts "The slice profile not specified."
return
}
if { $entries($w,b0inhtime_yn) == 1 && $entries($w,motion_yn) == 1 } {
puts "Warning: At the moment B0 field changing in time can not be simulated while the object is moving. This will be implemented into POSSUM at a later stage."
return
}
# Custom pulse : Check if pulse sequnce files exist
if { $entries($w,custompulse_yn) == 1 } {
foreach i [list "$entries($w,cuspulse)" "$entries($w,cuspulse).info" "$entries($w,cuspulse).posx" "$entries($w,cuspulse).posy" "$entries($w,cuspulse).posz" ] {
if { [file exists $i] == 0 } {
puts "Error! Custom pulse file : '$i' not found!"
return
}
}
}
# checks if the object is the same size as the b0file
if { $entries($w,b0inh_yn) == 1 } {
if { $entries($w,vcX) != $entries($w,vcXb0) || $entries($w,vcY) != $entries($w,vcYb0) || $entries($w,vcZ) != $entries($w,vcZb0) || $entries($w,inNx) != $entries($w,inNxb0) || $entries($w,inNy) != $entries($w,inNyb0) || $entries($w,inNz) != $entries($w,inNzb0) } {
puts "The object and the B0 file do not match in dimension or voxel size."
puts "Object dim: $entries($w,inNx), $entries($w,inNy), $entries($w,inNz)"
puts "B0 dim: $entries($w,inNxb0), $entries($w,inNyb0), $entries($w,inNzb0)"
puts "Object voxsize: $entries($w,vcX), $entries($w,vcY), $entries($w,vcZ)"
puts "B0 voxsize: $entries($w,vcXb0), $entries($w,vcYb0), $entries($w,vcZb0)"
return
}
}
# checks if the object is the same size as the b0time file
if { $entries($w,b0inhtime_yn) == 1 } {
if { $entries($w,vcX) != $entries($w,vcXb0time) || $entries($w,vcY) != $entries($w,vcYb0time) || $entries($w,vcZ) != $entries($w,vcZb0time) || $entries($w,inNx) != $entries($w,inNxb0time) || $entries($w,inNy) != $entries($w,inNyb0time) || $entries($w,inNz) != $entries($w,inNzb0time) } {
puts "The object and the B0 file (time changing) do not match in dimension or voxel size."
puts "Object dim: $entries($w,inNx), $entries($w,inNy), $entries($w,inNz)"
puts "B0 dim: $entries($w,inNxb0time), $entries($w,inNyb0time), $entries($w,inNzb0time)"
puts "Object voxsize: $entries($w,vcX), $entries($w,vcY), $entries($w,vcZ)"
puts "B0 voxsize: $entries($w,vcXb0time), $entries($w,vcYb0time), $entries($w,vcZb0time)"
return
}
}
if { $entries($w,activ_yn) == 1 } {
if { $entries($w,vcX) != $entries($w,vcXact) || $entries($w,vcY) != $entries($w,vcYact) || $entries($w,vcZ) != $entries($w,vcZact) || $entries($w,inNx) != $entries($w,inNxact) || $entries($w,inNy) != $entries($w,inNyact) || $entries($w,inNz) != $entries($w,inNzact) } {
puts "The object and the activation file do not match in dimension or voxel size."
puts "Object dim: $entries($w,inNx), $entries($w,inNy), $entries($w,inNz)"
puts "Activation dim: $entries($w,inNxact), $entries($w,inNyact), $entries($w,inNzact)"
puts "Object voxsize: $entries($w,vcX), $entries($w,vcY), $entries($w,vcZ)"
puts "Activation voxsize: $entries($w,vcXact), $entries($w,vcYact), $entries($w,vcZact)"
return
}
}
#checks if the output voxel size is smaller than the input voxel size
if { $entries($w,vcX) > $entries($w,outsize_dx) || $entries($w,vcY) > $entries($w,outsize_dy) || $entries($w,vcZ) > $entries($w,outsize_dz)} {
puts "The input object voxel size (every direction) should not be bigger than the output image voxel size."
puts "The input object voxel size: $entries($w,vcX), $entries($w,vcY), $entries($w,vcZ) "
puts "The output image voxel size: $entries($w,outsize_dx), $entries($w,outsize_dy), $entries($w,outsize_dz)"
return
}
#check if pulse is properly set up
Possum:pulsecheck $w
if { $entries($w,pulsechecktest) == 0 } {
puts "Error in pulse sequence!"
return
}
puts "Creating the POSSUM directory..."
puts ""
if { $entries($w,out) == "" } {
puts "The output directory not specified."
exit
} else {
new_file $entries($w,out)
catch { exec sh -c "mkdir $entries($w,out)" } oval
}
possum:write $w $entries($w,out)/possum.fsf
# now do some logic to figure out the parameters to pass on
if { $entries($w,b0inh_yn) == 0 } {
set b0file ""
} else {
set b0file $entries($w,b0f)
}
if { $entries($w,b0inhtime_yn) == 0 } {
set b0filetime ""
set b0filetimecourse ""
} else {
set b0filetime $entries($w,b0ftime)
set b0filetimecourse $entries($w,b0ftimecourse)
}
if { $entries($w,motion_yn) == 0 } {
set motfile "${FSLDIR}/data/possum/zeromotion"
} else {
set motfile $entries($w,userintmotfile)
}
if { $entries($w,activ_yn) == 0 } {
set act1file ""
set act2file ""
} else {
set act1file $entries($w,act1)
set act2file $entries($w,act2)
}
set filename "$entries($w,out)/noise"
set log [open "$filename" w]
if { $entries($w,noiseunits) == "snr" && $entries($w,noise_yn) == 1 } {
puts $log "snr $entries($w,noisesnr) "
} else {
puts $log "sigma $entries($w,noisesigma) "
}
close $log
set status [ possum:proc $w $entries($w,proctime) $entries($w,obvol) $entries($w,mrpar) $entries($w,seqtype) $entries($w,te) $entries($w,tr) $entries($w,trslc) $entries($w,outsize_nx) $entries($w,outsize_ny) $entries($w,outsize_nz) $entries($w,outsize_dx) $entries($w,outsize_dy) $entries($w,outsize_dz) $entries($w,fov_x) $entries($w,fov_y) $entries($w,fov_z) $entries($w,numvol) $entries($w,zstart) $entries($w,gap) $entries($w,bw) $entries($w,readgrad) $entries($w,phencode) $entries($w,slcselect) $entries($w,plus) $entries($w,maxG) $entries($w,riseT) $b0file $entries($w,b0fieldstrength) $entries($w,b0units) $b0filetime $b0filetimecourse $entries($w,b0unitstime) $entries($w,userintmotfile) $act1file $act2file $entries($w,out) $entries($w,numproc) $entries($w,segs) $entries($w,slcprof) $entries($w,cover) $entries($w,flipangle) $entries($w,slcsampfactor) ]
update idletasks
puts "Job submitted."
puts ""
puts "You can follow the POSSUM process by looking at the possum.log file."
puts ""
puts "If you want to see the individual processes see the logs directory."
}
proc Possum:makedir { w } {
global entries FSLDIR
# start by saving the fsf file (with all variables as they are now)
#if { ! [ file isdirectory $entries($w,out) ] } {
#catch { exec sh -c "mkdir $entries($w,out)" } oval
#}
if { $entries($w,obvol) == "" } {
puts "The input object not specified."
return
}
if { $entries($w,mrpar) == "" } {
puts "The input MR parameters not specified."
return
}
if { $entries($w,slcprof) == "" } {
puts "The slice profile not specified."
return
}
# Custom pulse : Check if pulse sequnce files exist
if { $entries($w,custompulse_yn) == 1 } {
foreach i [list "$entries($w,cuspulse)" "$entries($w,cuspulse).info" "$entries($w,cuspulse).posx" "$entries($w,cuspulse).posy" "$entries($w,cuspulse).posz" ] {
if { [file exists $i] == 0 } {
puts "Error! Custom pulse file : '$i' not found!"
return
}
}
}
if { $entries($w,b0inhtime_yn) == 1 && $entries($w,motion_yn) == 1 } {
puts "Warning: At the moment B0 field changing in time can not be simulated while the object is moving. This will be implemented into POSSUM at a later stage."
return
}
# checks if the object is the same size as the b0file
if { $entries($w,b0inh_yn) == 1 } {
if { $entries($w,vcX) != $entries($w,vcXb0) || $entries($w,vcY) != $entries($w,vcYb0) || $entries($w,vcZ) != $entries($w,vcZb0) || $entries($w,inNx) != $entries($w,inNxb0) || $entries($w,inNy) != $entries($w,inNyb0) || $entries($w,inNz) != $entries($w,inNzb0) } {
puts "The object and the B0 file do not match in dimension or voxel size."
puts "Object dim: $entries($w,inNx), $entries($w,inNy), $entries($w,inNz)"
puts "B0 dim: $entries($w,inNxb0), $entries($w,inNyb0), $entries($w,inNzb0)"
puts "Object voxsize: $entries($w,vcX), $entries($w,vcY), $entries($w,vcZ)"
puts "B0 voxsize: $entries($w,vcXb0), $entries($w,vcYb0), $entries($w,vcZb0)"
return
}
}
# checks if the object is the same size as the b0time file
if { $entries($w,b0inhtime_yn) == 1 } {
if { $entries($w,vcX) != $entries($w,vcXb0time) || $entries($w,vcY) != $entries($w,vcYb0time) || $entries($w,vcZ) != $entries($w,vcZb0time) || $entries($w,inNx) != $entries($w,inNxb0time) || $entries($w,inNy) != $entries($w,inNyb0time) || $entries($w,inNz) != $entries($w,inNzb0time) } {
puts "The object and the B0 file (time changing) do not match in dimension or voxel size."
puts "Object dim: $entries($w,inNx), $entries($w,inNy), $entries($w,inNz)"
puts "B0 dim: $entries($w,inNxb0time), $entries($w,inNyb0time), $entries($w,inNzb0time)"
puts "Object voxsize: $entries($w,vcX), $entries($w,vcY), $entries($w,vcZ)"
puts "B0 voxsize: $entries($w,vcXb0time), $entries($w,vcYb0time), $entries($w,vcZb0time)"
return
}
}
if { $entries($w,activ_yn) == 1 } {
if { $entries($w,vcX) != $entries($w,vcXact) || $entries($w,vcY) != $entries($w,vcYact) || $entries($w,vcZ) != $entries($w,vcZact) || $entries($w,inNx) != $entries($w,inNxact) || $entries($w,inNy) != $entries($w,inNyact) || $entries($w,inNz) != $entries($w,inNzact) } {
puts "The object and the activation file do not match in dimension or voxel size."
puts "Object dim: $entries($w,inNx), $entries($w,inNy), $entries($w,inNz)"
puts "Activation dim: $entries($w,inNxact), $entries($w,inNyact), $entries($w,inNzact)"
puts "Object voxsize: $entries($w,vcX), $entries($w,vcY), $entries($w,vcZ)"
puts "Activation voxsize: $entries($w,vcXact), $entries($w,vcYact), $entries($w,vcZact)"
return
}
}
#checks if the output voxel size is smaller than the input voxel size
if { $entries($w,vcX) > $entries($w,outsize_dx) || $entries($w,vcY) > $entries($w,outsize_dy) || $entries($w,vcZ) > $entries($w,outsize_dz)} {
puts "The input object voxel size (every direction) should not be bigger than the output image voxel size."
puts "The input object voxel size: $entries($w,vcX), $entries($w,vcY), $entries($w,vcZ) "
puts "The output image voxel size: $entries($w,outsize_dx), $entries($w,outsize_dy), $entries($w,outsize_dz)"
return
}
#check if pulse is properly set up
Possum:pulsecheck $w
if { $entries($w,pulsechecktest) == 0 } {
puts "Error in pulse sequence!"
return
}
if { $entries($w,out) == "" } {
puts "The output directory not specified."
exit
} else {
new_file $entries($w,out)
catch { exec sh -c "mkdir $entries($w,out)" } oval
}
possum:write $w $entries($w,out)/possum.fsf
# now do some logic to figure out the parameters to pass on
if { $entries($w,b0inh_yn) == 0 } {
set b0file ""
} else {
set b0file $entries($w,b0f)
}
if { $entries($w,b0inhtime_yn) == 0 } {
set b0filetime ""
set b0filetimecourse ""
} else {
set b0filetime $entries($w,b0ftime)
set b0filetimecourse $entries($w,b0ftimecourse)
}
if { $entries($w,motion_yn) == 0 } {
set motfile "${FSLDIR}/data/possum/zeromotion"
} else {
set motfile $entries($w,userintmotfile)
}
if { $entries($w,activ_yn) == 0 } {
set act1file ""
set act2file ""
} else {
set act1file $entries($w,act1)
set act2file $entries($w,act2)
}
set filename "$entries($w,out)/noise"
set log [open "$filename" w]
if { $entries($w,noiseunits) == "snr" && $entries($w,noise_yn) == 1 } {
puts $log "snr $entries($w,noisesnr) "
} else {
puts $log "sigma $entries($w,noisesigma) "
}
close $log
set status [ possum:procmakedir $w $entries($w,proctime) $entries($w,obvol) $entries($w,mrpar) $entries($w,seqtype) $entries($w,te) $entries($w,tr) $entries($w,trslc) $entries($w,outsize_nx) $entries($w,outsize_ny) $entries($w,outsize_nz) $entries($w,outsize_dx) $entries($w,outsize_dy) $entries($w,outsize_dz) $entries($w,fov_x) $entries($w,fov_y) $entries($w,fov_z) $entries($w,numvol) $entries($w,zstart) $entries($w,gap) $entries($w,bw) $entries($w,readgrad) $entries($w,phencode) $entries($w,slcselect) $entries($w,plus) $entries($w,maxG) $entries($w,riseT) $b0file $entries($w,b0fieldstrength) $entries($w,b0units) $b0filetime $b0filetimecourse $entries($w,b0unitstime) $motfile $act1file $act2file $entries($w,out) $entries($w,numproc) $entries($w,segs) $entries($w,slcprof) $entries($w,cover) $entries($w,flipangle) $entries($w,slcsampfactor)]
update idletasks
}
proc possum:previewimage { w } {
global entries FSLDIR
set convertcom "${FSLDIR}/bin/pngappend"
set filenm $entries($w,obvol)
set validim 0
catch { exec sh -c "${FSLDIR}/bin/imtest $filenm" } oval