-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathNM_PulseTab.ipf
More file actions
2296 lines (1574 loc) · 59.3 KB
/
NM_PulseTab.ipf
File metadata and controls
2296 lines (1574 loc) · 59.3 KB
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
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
#pragma hide = 1
//****************************************************************
//****************************************************************
//
// NeuroMatic: data aquisition, analyses and simulation software that runs with the Igor Pro environment
// Copyright (C) 2024 The Silver Lab, UCL
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// Contact [email protected]
// www.NeuroMatic.ThinkRandom.com
//
//****************************************************************
//****************************************************************
Static Constant NumWavesDefault = 1
Static Constant DeltaxDefault = 0.1
Static Constant WaveLengthDefault = 100
Static StrConstant WavePrefixDefault = "Pulse"
Static StrConstant ConfigWaveName = "PulseParamLists"
//****************************************************************
//****************************************************************
Function /S NMTabPrefix_Pulse() // this function allows NM to determine tab name and prefix
return "PU_"
End // NMTabPrefix_Pulse
//****************************************************************
//****************************************************************
Function NMPulseSubfolderExists()
String sf, wavePrefix
if ( exists( "CurrentPrefixPulse" ) == 2 )
wavePrefix = StrVarOrDefault( "CurrentPrefixPulse", "" )
if ( strlen( wavePrefix ) == 0 )
return 0
endif
sf = CurrentNMFolder( 1 ) + "Pulse_" + wavePrefix + ":"
if ( DataFolderExists( sf ) )
return 1
endif
endif
return 0
End // NMPulseSubfolderExists
//****************************************************************
//****************************************************************
Function /S NMPulseDF() // data folder where tab globals are stored
if ( NMPulseSubfolderExists() )
return CurrentNMFolder( 1 )
else
return NMPulseDF
endif
End // NMPulseDF
//****************************************************************
//****************************************************************
Function /S NMPulseSubfolder()
String sf, wavePrefix
if ( exists( "CurrentPrefixPulse" ) == 2 )
wavePrefix = StrVarOrDefault( "CurrentPrefixPulse", "" )
if ( strlen( wavePrefix ) > 0 )
sf = CurrentNMFolder( 1 ) + "Pulse_" + wavePrefix + ":"
if ( DataFolderExists( sf ) )
return sf // found a pulse subfolder
endif
endif
endif
wavePrefix = StrVarOrDefault( NMPulseDF + "CurrentPrefixPulse", "" )
if ( strlen( wavePrefix ) == 0 )
SetNMstr( NMPulseDF + "CurrentPrefixPulse", WavePrefixDefault )
wavePrefix = WavePrefixDefault
endif
return NMPulseDF + "Pulse_" + wavePrefix + ":"
End // NMPulseSubfolder
//****************************************************************
//****************************************************************
Function /S NMPulseSubfolderList( [ df, fullPath ] )
String df
Variable fullPath
String fList
String folderPrefix = "Pulse_"
if ( ParamIsDefault( df ) || ( strlen( df ) == 0 ) )
df = NMPulseDF()
elseif ( !DataFolderExists( df ) )
return NM2ErrorStr( 30, "df", df )
endif
return NMSubfolderList( folderPrefix, df, fullPath )
End // NMPulseSubfolderList
//****************************************************************
//****************************************************************
Static Function /S z_NMPulseWavePrefixNewCall()
String wavePrefix = ""
String pList = NMPulseWavePrefixList()
Prompt wavePrefix, "enter new pulse wave prefix:"
DoPrompt "Pulse Wave Prefix", wavePrefix
if ( V_flag == 1 )
return "" // cancel
endif
if ( WhichListItem( wavePrefix, pList ) >= 0 )
return "" // already exists
endif
NMPulseSet( wavePrefix = wavePrefix, history = 1 )
return wavePrefix
End // z_NMPulseWavePrefixNewCall
//****************************************************************
//****************************************************************
Static Function /S z_NMPulseWavePrefixKillCall()
String wavePrefix = CurrentNMPulseWavePrefix()
String pList = NMPulseWavePrefixList()
Prompt wavePrefix, "select wave prefix to kill:", popup pList
DoPrompt "Pulse Wave Prefix", wavePrefix
if ( V_flag == 1 )
return "" // cancel
endif
return NMPulseWavePrefixKill( wavePrefix = wavePrefix, history = 1 )
End // z_NMPulseWavePrefixKillCall
//****************************************************************
//****************************************************************
Function /S NMPulseWavePrefixKill( [ wavePrefix, update, history ] )
String wavePrefix
Variable update
Variable history
String subfolder, pList, vlist = ""
String thisfxn = GetRTStackInfo( 1 )
String df = NMPulseDF()
if ( ParamIsDefault( wavePrefix ) )
wavePrefix = CurrentNMPulseWavePrefix()
else
vlist = NMCmdStrOptional( "wavePrefix", wavePrefix, vlist )
endif
subfolder = df + "Pulse_" + wavePrefix + ":"
if ( !DataFolderExists( subfolder ) )
return "" // NM2ErrorStr( 30, "subfolder", subfolder )
endif
if ( StringMatch( subfolder, GetDataFolder( 1 ) ) == 1 )
NMDoAlert( thisfxn + " Abort: cannot close the current data folder." )
return "" // not allowed
endif
if ( ParamIsDefault( update ) )
update = 1
endif
if ( history )
NMCommandHistory( vlist )
endif
Variable error = NMSubfolderKill( subfolder )
if ( error == 0 )
pList = NMPulseWavePrefixList()
if ( ItemsInList( pList ) == 0 )
SetNMstr( df + "CurrentPrefixPulse", WavePrefixDefault )
else
SetNMstr( df + "CurrentPrefixPulse", StringFromList( 0, pList ) )
endif
else
subfolder = ""
endif
if ( update )
NMPulseUpdate()
endif
return subfolder
End // NMPulseWavePrefixKill
//****************************************************************
//****************************************************************
Function /S CurrentNMPulseWavePrefix()
String df = NMPulseDF()
String wavePrefix = StrVarOrDefault( df + "CurrentPrefixPulse", "" )
String subfolder = df + "Pulse_" + wavePrefix + ":"
if ( DataFolderExists( subfolder ) )
return wavePrefix
else
return ""
endif
End // CurrentNMPulseWavePrefix
//****************************************************************
//****************************************************************
Function /S NMPulseWavePrefixList( [ df ] )
String df
if ( ParamIsDefault( df ) || ( strlen( df ) == 0 ) )
df = NMPulseDF()
elseif ( !DataFolderExists( df ) )
return NM2ErrorStr( 30, "df", df )
endif
String fList = NMPulseSubfolderList( df = df )
String prefixList = ReplaceString( "Pulse_", fList, "" )
if ( ItemsInList( prefixList ) == 0 )
prefixList = "Pulse;"
endif
return prefixList
End // NMPulseWavePrefixList
//****************************************************************
//****************************************************************
Function PulseTab( enable ) // called my ChangeTab
Variable enable // ( 0 ) disable ( 1 ) enable tab
if ( enable == 1 )
CheckNMPackage( "Pulse", 1 ) // declare globals if necessary
NMPulseMake() // create tab controls if necessary
NMChannelGraphDisable( channel = -2, all = 0 )
endif
End // PulseTab
//****************************************************************
//****************************************************************
Function PulseTabKill( what ) // called my KillTab
String what
String df = NMPulseDF
strswitch( what )
case "waves":
// kill any other waves here
break
case "folder":
if ( DataFolderExists( df ) == 1 )
KillDataFolder $df
endif
break
endswitch
End // PulseTabKill
//****************************************************************
//****************************************************************
Function NMPulseCheck() // declare global variables
String df = NMPulseDF
String sf = NMPulseSubfolder()
if ( DataFolderExists( sf ) == 0 )
NewDataFolder $RemoveEnding( sf, ":" )
endif
CheckNMvar( sf + "NumWaves", NumWavesDefault )
CheckNMvar( sf + "DeltaX", DeltaxDefault )
CheckNMvar( sf + "WaveLength", WaveLengthDefault )
CheckNMstr( sf + "Xunits", NMXunits )
CheckNMstr( sf + "Yunits", "" )
CheckNMvar( sf + "PulseConfigNum", -1 )
CheckNMvar( df + "AutoExecute", 0 )
CheckNMvar( df + "OverwriteMode", 1 )
CheckNMvar( df + "PromptBinomial", 1 )
CheckNMstr( df + "PromptTypeDSCG", "stdv" )
CheckNMvar( df + "PromptPlasticity", 1 )
CheckNMvar( df + "WaveNotes", 1 )
CheckNMvar( df + "SaveStochasticValues", 1 )
CheckNMvar( df + "SavePlasticityWaves", 1 )
CheckNMvar( df + "TTL", 0 )
STRUCT NMPulseLBWaves lb
NMPulseTabLBWavesDefault( lb )
return 0
End // NMPulseCheck
//****************************************************************
//****************************************************************
Function /S NMPulseConfigWaveName()
return NMPulseSubfolder() + ConfigWaveName
End // NMPulseConfigWaveName
//****************************************************************
//****************************************************************
Function NMPulseTabLBWavesDefault( lb )
STRUCT NMPulseLBWaves &lb
String sf = NMPulseSubfolder()
lb.pcwName = sf + ConfigWaveName // same as NMPulseConfigWaveName()
lb.lb1wName = sf + "LB1Configs"
lb.lb1wNameSel = sf + "LB1ConfigsEditable"
lb.lb2wName = sf + "LB2Configs"
lb.lb2wNameSel = sf + "LB2ConfigsEditable"
lb.pcvName = sf + "LB1ConfigNum"
NMPulseLBWavesCheck( lb )
End // NMPulseTabLBWavesDefault
//****************************************************************
//****************************************************************
Function NMPulseVar( varName )
String varName
String df = NMPulseDF
String sf = NMPulseSubfolder()
strswitch( varName )
case "ConfigNum":
case "PulseConfigNum":
return NumVarOrDefault( sf + varName, -1 )
case "NumWaves":
return NumVarOrDefault( sf + varName, NumWavesDefault )
case "DeltaX":
return NumVarOrDefault( sf + varName, DeltaxDefault )
case "WaveLength":
return NumVarOrDefault( sf + varName, WaveLengthDefault )
case "AutoExecute":
return NumVarOrDefault( df + varName, 1 )
case "OverwriteMode":
return NumVarOrDefault( df + varName, 1 )
case "PromptBinomial":
return NumVarOrDefault( df + varName, 1 )
case "PromptPlasticity":
return NumVarOrDefault( df + varName, 1 )
case "WaveNotes":
return NumVarOrDefault( df + varName, 1 )
case "SaveStochasticValues":
return NumVarOrDefault( df + varName, 1 )
case "SavePlasticityWaves":
return NumVarOrDefault( df + varName, 1 )
case "TTL":
return NumVarOrDefault( df + varName, 0 )
endswitch
return NaN
End // NMPulseVar
//****************************************************************
//****************************************************************
Function /S NMPulseStr( varName )
String varName
String df = NMPulseDF()
String sf = NMPulseSubfolder()
strswitch( varName )
case "WavePrefix":
//return StrVarOrDefault( xsf + varName, WavePrefixDefault )
return StrVarOrDefault( df + "CurrentPrefixPulse", WavePrefixDefault )
case "Xunits":
return StrVarOrDefault( sf + varName, NMXunits )
case "Yunits":
return StrVarOrDefault( sf + varName, "" )
case "PromptTypeDSCG":
return StrVarOrDefault( NMPulseDF + varName, "stdv" )
endswitch
return ""
End // NMPulseStr
//****************************************************************
//****************************************************************
Function NMPulseConfigs()
NMConfigVar( "Pulse", "AutoExecute", 1, "auto compute waves after adding/editing pulses", "boolean" )
NMConfigVar( "Pulse", "OverwriteMode", 1, "overwrite existing waves, tables and graphs if their is a name conflict", "boolean" )
NMConfigVar( "Pulse", "PromptBinomial", 1, "prompt for binomial pulses", "boolean" )
NMConfigVar( "Pulse", "PromptPlasticity", 1, "prompt for plasticity of pulse trains", "boolean" )
NMConfigStr( "Pulse", "PromptTypeDSCG", "stdv", "prompt for \"delta\" or \"stdv\" or \"cv\" or \"gamma\" of pulse parameters", "delta;stdv;cv;gamma;" )
NMConfigVar( "Pulse", "WaveNotes", 1, "save pulse parameters to wave notes", "boolean" )
NMConfigVar( "Pulse", "SaveStochasticValues", 1, "save parameters that vary to output waves", "boolean" )
NMConfigVar( "Pulse", "SavePlasticityWaves", 1, "save plasticity states variables (e.g. D and F) to waves", "boolean" )
NMConfigVar( "Pulse", "TTL", 0, "sum waves using TTL logic", "boolean" )
End // NMPulseConfigs
//****************************************************************
//****************************************************************
Function NMPulseMake()
Variable x0 = 20, xinc = 140, yinc = 25, fs = NMPanelFsize
Variable y0 = NMPanelTabY + 35
NMPulseCheck()
String df = NMPulseDF
String sf = NMPulseSubfolder()
STRUCT NMPulseLBWaves lb
NMPulseTabLBWavesDefault( lb )
ControlInfo /W=$NMPanelName $"PU_configs"
if ( V_Flag != 0 )
NMPulseUpdate( stopAutoExecute = 1 )
return 0 // tab controls exist, return here
endif
DoWindow /F $NMPanelName
SetVariable PU_NumWaves, title="waves", pos={x0+xinc,y0}, limits={1,inf,0}, size={120,20}, win=$NMPanelName
SetVariable PU_NumWaves, value=$( sf+"NumWaves" ), fsize=fs, proc=NMPulseSetVariable, win=$NMPanelName
SetVariable PU_DeltaX, title="x-delta", pos={x0+xinc,y0+1*yinc}, limits={0,inf,0}, size={120,20}, win=$NMPanelName
SetVariable PU_DeltaX, value=$( sf+"DeltaX" ), fsize=fs, proc=NMPulseSetVariable, win=$NMPanelName
SetVariable PU_WaveLength, title="wave length", pos={x0+xinc,y0+2*yinc}, limits={0,inf,0}, size={120,20}, win=$NMPanelName
SetVariable PU_WaveLength, value=$( sf+"WaveLength" ), fsize=fs, proc=NMPulseSetVariable, win=$NMPanelName
//SetVariable PU_WavePrefix, title="wave prefix", pos={x0+xinc,y0}, size={120,20}, win=$NMPanelName
//SetVariable PU_WavePrefix, value=$( df+"WavePrefix" ), fsize=fs, proc=NMPulseSetVariable, win=$NMPanelName
PopupMenu PU_PrefixMenu, title=" ", pos={x0,y0-3}, size={120,20}, bodyWidth=120, win=$NMPanelName
PopupMenu PU_PrefixMenu, mode=1, value="Wave Prefix", fsize=fs, proc=NMPulsePopup, win=$NMPanelName
SetVariable PU_Xunits, title="x-units", pos={x0,y0+1*yinc}, size={120,20}, win=$NMPanelName
SetVariable PU_Xunits, value=$( sf+"Xunits" ), fsize=fs, proc=NMPulseSetVariable, win=$NMPanelName
SetVariable PU_Yunits, title="y-units", pos={x0,y0+2*yinc}, size={120,20}, win=$NMPanelName
SetVariable PU_Yunits, value=$( sf+"Yunits" ), fsize=fs, proc=NMPulseSetVariable, win=$NMPanelName
y0 += 80
ListBox PU_configs, pos={x0,y0}, size={260,100}, fsize=fs, listWave=$lb.lb1wName, selWave=$lb.lb1wNameSel, win=$NMPanelName
ListBox PU_configs, mode=1, userColumnResize=1, proc=NMPulseLB1Control, widths={25,1500}, win=$NMPanelName
y0 += 115
ListBox PU_params, pos={x0,y0}, size={260,120}, fsize=fs, listWave=$lb.lb2wName, selWave=$lb.lb2wNameSel, win=$NMPanelName
ListBox PU_params, mode=1, userColumnResize=1, selRow=-1, proc=NMPulseLB2Control, widths={35,70,45}, win=$NMPanelName
y0 += 135
yinc = 30
Button PU_Execute, pos={x0+20,y0}, title="Execute", size={100,20}, proc=NMPulseButton, fsize=fs, win=$NMPanelName
Button PU_Model, pos={x0+140,y0}, title="Model", size={100,20}, proc=NMPulseButton, fsize=fs, win=$NMPanelName
Button PU_Graph, pos={x0+20,y0+yinc}, title="Graph", size={100,20}, proc=NMPulseButton, fsize=fs, win=$NMPanelName
Button PU_Table, pos={x0+140,y0+yinc}, title="Table", size={100,20}, proc=NMPulseButton, fsize=fs, win=$NMPanelName
//Button PU_Clear, pos={x0+55,y0+yinc}, title="Remove", size={70,20}, proc=NMPulseButton, fsize=fs, win=$NMPanelName
y0 += 65
CheckBox PU_AutoExecute, title="auto execute", pos={x0+125,y0}, size={200,50}, value=0, proc=NMPulseCheckBox, fsize=fs, win=$NMPanelName
NMPulseUpdate( stopAutoExecute = 1 )
End // NMPulseMake
//****************************************************************
//****************************************************************
Function NMPulseUpdate( [ stopAutoExecute ] )
Variable stopAutoExecute
Variable configNum
String sf, wavePrefix
Variable auto = NMPulseVar( "AutoExecute" )
Variable editByPrompt = NMVarGet( "ConfigsEditByPrompt" )
STRUCT NMPulseLBWaves lb
NMPulseCheck()
sf = NMPulseSubfolder()
NMPulseTabLBWavesDefault( lb )
if ( !WaveExists( $lb.pcwName ) || ( numpnts( $lb.pcwName ) == 0 ) )
configNum = -1
else
configNum = NumVarOrDefault( lb.pcvName, 0 )
endif
PopupMenu PU_PrefixMenu, mode=1, value=NMPulseWavePrefixMenu(), popvalue=CurrentNMPulseWavePrefix(), win=$NMPanelName
SetVariable PU_NumWaves, value=$( sf + "NumWaves" ), win=$NMPanelName
SetVariable PU_DeltaX, value=$( sf + "DeltaX" ), win=$NMPanelName
SetVariable PU_WaveLength, value=$( sf + "WaveLength" ), win=$NMPanelName
SetVariable PU_Xunits, value=$( sf + "Xunits" ), win=$NMPanelName
SetVariable PU_Yunits, value=$( sf + "Yunits" ), win=$NMPanelName
CheckBox PU_AutoExecute, value=auto, win=$NMPanelName
ListBox PU_configs, listWave=$lb.lb1wName, selWave=$lb.lb1wNameSel, selRow=( configNum ), win=$NMPanelName
ListBox PU_params, listWave=$lb.lb2wName, selWave=$lb.lb2wNameSel, selRow=-1, win=$NMPanelName
NMPulseLB1Update( lb )
NMPulseLB2Update( lb, editByPrompt=editByPrompt )
if ( !stopAutoExecute && auto )
NMPulseExecute()
endif
End // NMPulseUpdate
//****************************************************************
//****************************************************************
Function /S NMPulseWavePrefixMenu()
return "Wave Prefix;---;" + NMPulseWavePrefixList() + "---;Other;Kill;"
End // NMPulseWavePrefixMenu
//****************************************************************
//****************************************************************
Function NMPulseButton( ctrlName ) : ButtonControl
String ctrlName
String fxn = ReplaceString( NMTabPrefix_Pulse(), ctrlName, "" )
NMPulseCall( fxn, "" )
End // NMPulseButton
//****************************************************************
//****************************************************************
Function NMPulseSetVariable( ctrlName, varNum, varStr, varName ) : SetVariableControl
String ctrlName; Variable varNum; String varStr; String varName
String fxn = ReplaceString( NMTabPrefix_Pulse(), ctrlName, "" )
NMPulseCall( fxn, varStr )
End // NMPulseSetVariable
//****************************************************************
//****************************************************************
Function NMPulseCheckBox( ctrlName, checked ) : CheckBoxControl
String ctrlName; Variable checked
ctrlName = ReplaceString( "PU_", ctrlName, "" )
NMPulseCall( ctrlName, num2istr( checked ) )
End // NMPulseCheckBox
//****************************************************************
//****************************************************************
Function NMPulsePopup(ctrlName, popNum, popStr) : PopupMenuControl
String ctrlName; Variable popNum; String popStr
ctrlName = ReplaceString( "PU_", ctrlName, "" )
if ( StringMatch( ctrlName, "PrefixMenu" ) )
strswitch( popStr)
case "---":
case "Wave Prefix":
break
case "Other":
z_NMPulseWavePrefixNewCall()
break
case "Kill":
z_NMPulseWavePrefixKillCall()
break
default:
NMPulseSet( wavePrefix = popStr, history = 1 )
endswitch
endif
End // NMPulsePopup
//****************************************************************
//****************************************************************
Function NMPulseLB1Control( ctrlName, row, col, event ) : ListboxControl
String ctrlName // name of this control
Variable row // row if click in interior, -1 if click in title
Variable col // column number
Variable event // event code
// 1 - mouse down
// 2 - mouse up
// 3 - double click
// 4 - cell selection
// 6 - begin cell edit
// 7 - end cell edit
// 13 - checkbox clicked
String paramList, ood, titleStr, trainStr
String sf = NMPulseSubfolder()
Variable editByPrompt = NMVarGet( "ConfigsEditByPrompt" )
STRUCT NMPulseLBWaves lb
NMPulseTabLBWavesDefault( lb )
String estr = NMPulseLB1Event( row, col, event, lb )
if ( StringMatch( estr, "+" ) )
paramList = NMPulseLB1PromptNew()
if ( ItemsInList( paramList ) > 0 )
return NMPulseConfigAdd( paramList, history = 1 )
endif
elseif ( StringMatch( estr, "-" ) )
ood = NMPulseLB1PromptOODE( lb, sf )
NMPulseConfigOODE( lb, sf, ood )
else
NMPulseLB2Update( lb, editByPrompt=editByPrompt )
endif
End // NMPulseLB1Control
//****************************************************************
//****************************************************************
Function NMPulseLB2Control( ctrlName, row, col, event ) : ListboxControl
String ctrlName // name of this control
Variable row // row if click in interior, -1 if click in title
Variable col // column number
Variable event // event code
// 1 - mouse down
// 2 - mouse up
// 3 - double click
// 4 - cell selection
// 6 - begin cell edit
// 7 - end cell edit
// 13 - checkbox clicked
Variable numWaves = NMPulseVar( "NumWaves" )
Variable TTL = NMPulseVar( "TTL" )
String sf = NMPulseSubfolder()
String timeUnits = NMPulseStr( "Xunits" )
String ampUnits = NMPulseStr( "Yunits" )
STRUCT NMPulseLBWaves lb
NMPulseTabLBWavesDefault( lb )
NMPulseLB2Event( row, col, event, lb, numWaves=numWaves, TTL=TTL, timeUnits=timeUnits, ampUnits=ampUnits )
NMPulseUpdate()
End // NMPulseLB2Control
//****************************************************************
//****************************************************************
Function /S NMPulseCall( fxn, select )
String fxn // function name
String select // parameter string variable
Variable snum = str2num( select ) // parameter variable number
String df = NMPulseDF
strswitch( fxn )
case "AutoExecute":
NMConfigVarSet( "Pulse", "AutoExecute", BinaryCheck( snum ) )
break
case "Execute":
return NMPulseExecute( history = 1 )
case "Graph":
return NMMainCall( "Graph", "" )
case "Table":
return NMPulseTableCall()
case "Clear":
NMPulseConfigRemoveCall()
break
case "Model":
NMPulseModelsCall()
break
case "WavePrefix":
NMPulseSet( wavePrefix = select, history = 1 )
break
case "NumWaves":
NMPulseSet( numWaves = snum, history = 1 )
break
case "DeltaX":
NMPulseSet( dx = snum, history = 1 )
break
case "WaveLength":
NMPulseSet( waveLength = snum, history = 1 )
break
case "Xunits":
NMPulseSet( xunits = select, history = 1 )
break
case "Yunits":
NMPulseSet( yunits = select, history = 1 )
break
endswitch
return ""
End // NMPulseCall
//****************************************************************
//****************************************************************
Function NMPulseSet( [ wavePrefix, numWaves, dx, waveLength, xunits, yunits, update, history ] )
String wavePrefix
Variable numWaves, dx, waveLength
String xunits, yunits
Variable update
Variable history // print function command to history ( 0 ) no ( 1 ) yes
String vlist = ""
String df = NMPulseDF()
String sf = NMPulseSubfolder()
if ( ParamIsDefault( update ) )
update = 1
endif
if ( !ParamIsDefault( wavePrefix ) && ( strlen( wavePrefix ) > 0 ) )
vlist = NMCmdStrOptional( "wavePrefix", wavePrefix, vlist )
SetNMstr( df + "CurrentPrefixPulse", wavePrefix )
endif
if ( !ParamIsDefault( xunits ) && ( strlen( xunits ) > 0 ) )
vlist = NMCmdStrOptional( "xunits", xunits, vlist )
SetNMstr( sf + "Xunits", xunits )
endif
if ( !ParamIsDefault( yunits ) && ( strlen( yunits ) > 0 ) )
vlist = NMCmdStrOptional( "yunits", yunits, vlist )
SetNMstr( sf + "Yunits", yunits )
endif
if ( !ParamIsDefault( numWaves ) && ( numWaves > 0 ) )
vlist = NMCmdNumOptional( "numWaves", numWaves, vlist )
SetNMvar( sf + "NumWaves", numWaves )
endif
if ( !ParamIsDefault( dx ) && ( dx > 0 ) )
vlist = NMCmdNumOptional( "dx", dx, vlist )
SetNMvar( sf + "DeltaX", dx )
endif
if ( !ParamIsDefault( waveLength ) && ( waveLength > 0 ) )
vlist = NMCmdNumOptional( "waveLength", waveLength, vlist )
SetNMvar( sf + "WaveLength", waveLength )
endif
if ( history )
NMCommandHistory( vlist )
endif
if ( update )
NMPulseUpdate()
endif
End // NMPulseSet
//****************************************************************
//****************************************************************
Function /S NMPulseLB1PromptNew()
String titleEnding = ""
String sf = NMPulseSubfolder()
Variable numWaves = NMPulseVar( "NumWaves" )
Variable waveLength = NMPulseVar( "WaveLength" )
Variable TTL = NMPulseVar( "TTL" )
Variable binom = NMPulseVar( "PromptBinomial" )
Variable plasticity = NMPulseVar( "PromptPlasticity" )
String DSCG = NMPulseStr( "PromptTypeDSCG" )
String timeUnits = NMPulseStr( "Xunits" )
String ampUnits = NMPulseStr( "Yunits" )
return NMPulsePrompt( udf=sf, pdf=NMPulseDF, numWaves=numWaves, timeLimit=waveLength, TTL=TTL, titleEnding=titleEnding, binom=binom, DSC=DSCG, plasticity=plasticity, timeUnits=timeUnits, ampUnits=ampUnits )
End // NMPulseLB1PromptNew
//****************************************************************
//****************************************************************
Function NMPulseConfigAdd( paramList [ pcwName, update, history ] )
String paramList
String pcwName
Variable update
Variable history
Variable error
String cmd
String sf = NMPulseSubfolder()
String bullet = NMCmdHistoryBullet()
Variable cmdhistory = NMVarGet( "CmdHistory" )
if ( ParamIsDefault( pcwName ) )
pcwName = NMPulseConfigWaveName()
endif
if ( ParamIsDefault( update ) )
update = 1
endif
if ( cmdhistory && history )
cmd = GetRTStackInfo( 1 ) + "( \"" + paramList + "\" )"
NMHistoryManager( bullet + cmd, -1 * cmdhistory )
endif
error = NMPulseConfigWaveSave( pcwName, paramList )
if ( update )
NMPulseUpdate()
endif
return error
End // NMPulseConfigAdd
//****************************************************************
//****************************************************************
Function NMPulseConfigRemoveCall()
Variable select = 1
String pcwName = NMPulseConfigWaveName()
Prompt select, " ", popup "clear all pulse configs;turn off all pulse configs;turn on all pulse configs;"
DoPrompt "NM Pulse Configs", select
if ( V_flag == 1 )
return 0 // cancel
endif
if ( select == 1 )
return NMPulseConfigRemove( all = 1 )
elseif ( select == 2 )
return NMPulseConfigRemove( all = 1, off = 1 )
elseif ( select == 3 )
return NMPulseConfigRemove( all = 1, off = 0 )
endif
End // NMPulseConfigRemoveCall
//****************************************************************
//****************************************************************
Function NMPulseConfigOODE( lb, udf, ood [ noPrompt ] ) // code copied from NMPulseLB1OODE()
STRUCT NMPulseLBWaves &lb
String udf // data folder where user waves are located
String ood // see NMPulseLB1PromptOOD
Variable noPrompt // for delete
Variable configNum, deleteAll = 0
Variable deleteTrain = 2 // user prompt to delete
String trainStr, titleStr
if ( !WaveExists( $lb.pcwName ) )