Med_Support

Forum Replies Created

Viewing 33 posts - 1 through 33 (of 305 total)
  • Author
    Posts
  • in reply to: Output Module for Radial Arm/Elevated Plus Maze #16873
    Med_Support
    Moderator

    Hi,

    This forum is generally used for coding questions.
    Please contact support@med-associates.com for hardware and general software questions.

    Yes, you will need a TTL output module and you will need to configure the module in MED-PC and also update the RAM code to turn on those TTL signals during the protocol.

    Regards,
    Med Support

    in reply to: Show detailed locomotion data #16864
    Med_Support
    Moderator

    Hi,

    Do you have hardware that is capturing X and Y data?
    I am unaware of any MED-PC chambers that have both.

    in reply to: Constant Pressing for Pellet Drop #16796
    Med_Support
    Moderator

    Remove only the bottom screw on the card (under part number DIG-716).
    Screw cable into card and pull from the cable firmly but gently.

    in reply to: Constant Pressing for Pellet Drop #16776
    Med_Support
    Moderator

    The SmartCtrl inputs have 2 settings Toggle vs. Level.
    to time the lever press you would need to set the input to level mode. This is a hardware setting that will require you to take the card out and physically switch the input to level mode.

    Pseudo code: *update Y to 40 for .4 second hold.
    \***************************************************
    \ RESPONSE DEFINED – 20ms BREAK, 20ms RELEASE
    \***************************************************
    S.S.2,
    S1, \ Inputs in Level Mode generate an input “count” on each
    \ interrupt. With a 10 ms system resolution 2 counts will
    \ be reached in 20 ms. The Z^LeftBreak pulse is used to
    \ signal a completed Response. The second statement resets
    \ the counter every 20 ms so that a partial Response of
    \ less than 20 ms will not be counted.
    #R^LeftLever: ADD Y; IF Y >= 2 [@Response, @NoResponse]
    @Response: SET Y = 0; Z^LeftBreak —> S2
    @NoResponse: —> SX
    0.02″: SET Y = 0 —> S1

    in reply to: Pavlovian instrumental transfer coding #16734
    Med_Support
    Moderator

    I am not sure I really understand what problems you are having.

    Please email support@med-associates.com with your .mpc code attached (not pasted) and a clear explanation of what the code is doing or not doing and what it is you want it to do.

    Med_Support
    Moderator

    The SG-215D and SG-215D4 only work with SuperPort cards.
    Please contact support@med-associates.com for further questions.

    in reply to: Alternating level cyclic ratio #15911
    Med_Support
    Moderator

    Please contact support@med-associates.com for further support.

    in reply to: Alternating level cyclic ratio #15909
    Med_Support
    Moderator

    It sounds like you want to alternate the correct lever every successful PR with the associated stim light?

    You would need to update the A(^CorrectLev) when you update the PR in S5. You could also turn on the correct stim light at this time.

    Example:
    S5, \ Time Out Interval Following Reward
    \ Update Progressive Ratio P from LIST Z
    A(^TimeOutTicks)#T: LIST P = Z(X);
    IF A(^CorrectLev) = 1 [@True, @False]
    @True: SET A(^CorrectLev) = 2; ON ^RightLight —> S2
    @True: SET A(^CorrectLev) = 1; ON ^LeftLight —> S2

    #Z^Z_End: —> S5

    in reply to: Random Ratio schedule #15729
    Med_Support
    Moderator

    Hello Natasha,

    I am including a sample code below that should give you a basic guide on how to do a random ratio schedule.

    Below you will see I have made a list Z. I have included 5 elements in Z to show the .2 probability you mentioned.
    I am using the variable A to represent the number picked randomly from List Z.

    Med PC uses two different functions for random operations, RANDD and RANDI. The difference between the two is that RANDD does not use replacement, but will randomly pick a number from a list and then that number won’t be picked again until every number on the list has been picked.

    RANDI will randomly pick a number from the list and then put it back into the list where it can be chosen again.

    The sample code below begins with a #START command, then moving into S2 where 1 second passes and then the RANDI function makes the variable A equal to a number randomly picked from Z. We then move to S3 where the code waits for a certain number of left lever presses dictated by whatever number A is.

    After that many presses, a Z1 pulse is created. In this, I made Z1 be what would distribute the reward. In State Set 2, I added a line that waits for the reward to be given before updating a show field that displays how many times a reward has been given.

    ^LeftLever = 1

    \ A = Ratio Value Drawn from List Z
    \ Z() = Variable Ratio Array

    \ Z Pulse
    \ Z1 = Reward Output
    LIST Z = 1, 2, 3, 4, 5

    S.S.1
    S1,
    #START: —> S2

    S2,
    1″: RANDI A = Z —> S3

    S3,
    A#R^LeftLever: Z1 —> S2

    S.S.2
    S1,
    #Z1: ADD X; SHOW 1, Rewards Issued, X —> S1

    You can also find a more in depth explanation of how RANDD and RANDI work in the MED-PC Programmer’s Manual found in the Manuals section of our website. The manual also includes a step by step tutorial that would help you familiarize yourself with some of the more common functions of Med State Notation.

    in reply to: acquisition and reversal #15448
    Med_Support
    Moderator
    in reply to: Drug Discrimination #15418
    Med_Support
    Moderator

    The errors you are having are becaue you copied it in from a word processor or outlook. “” replace the directional quotes for normal quotes.

    in reply to: Drug Discrimination #15416
    Med_Support
    Moderator

    Agata,

    Looks like you already have a code that will end the protocol when 15 minutes elapses. T(0)#T = 15′ in your code.
    You could also hard code 15′: instead of T(0)#T:.

    LIST T = 15′, 5″

    S.S.1,
    S1,
    #START: ON ^HouseLight, —> S2
    S2,
    T(0)#T: —> S3
    S3,
    0.01″: OFF ^HouseLight, —> STOPABORTFLUSH

    There is a more elegant way to code the above which is what you will use to stop when a # max rewards has been made with an IF statement.

    \\\SESSION TIMER\\\
    S.S.1,
    S1, \ Time Session Length
    0.01″: SET S = S + 0.01;
    SHOW 7,Session,S;
    IF S/60 >= 15 [@End, @Cont]
    @End: —> STOPABORTFLUSH
    @Cont: —> SX

    \\\MAX REWARDS\\\
    \**************************************************
    \ PELLET CONTROL TIMER
    \ (Includes K1-pulse for delivering a free pellet)
    \**************************************************
    S.S.4,
    S1,
    #Z1: ADD R; SHOW 8,Rewards,R; ON ^Pellet —> S2
    #K1: ADD D; SHOW 4,Free Pellets,D; ON ^Pellet —> S2

    S2,
    0.05″: OFF ^Pellet;
    IF R >= 50 [@End, @Cont]
    @End: —> STOPABORTFLUSH
    @Cont: —> S1

    in reply to: Fear Conditioning Program #15363
    Med_Support
    Moderator

    Hi Sean,

    This forum is for specific MSN coding questions.
    There are many ways to code a fear conditioning protocol.
    The code you seem to want seems very simple to code if you are familiar with MSN code.

    I would recommend using/going through the Programmers manual to try to write this and if something is not working as intended, reach out to the forum or email support@med-associates.com. Below is the link to Programmers manual.

    https://mednr.com/wp-content/uploads/2017/01/DOC-003-R3.4-SOF-735-MED-PC-IV-PROGRAMMER%E2%80%99S-MANUAL.pdf

    Regards,

    in reply to: 1″ does not equal 1″ #13593
    Med_Support
    Moderator
    tyrsu

    I know – I don’t know what they were thinking!
    Increasing it to 100 would have been weird enough – but 400 ms just makes no sense at all.

    Thanks for all your help, Gary!

    in reply to: 1″ does not equal 1″ #13591
    Med_Support
    Moderator
    Gary Bamberger

    I’m glad that you figured it out. It is very unusual to find the resolution has been changed to 400ms. Going from 10ms to 1ms is very common, but almost nobody does the other direction.

    Gary

    in reply to: 1″ does not equal 1″ #13588
    Med_Support
    Moderator
    tyrsu

    Thanks Gary!

    I figured out that it is because whoever installed the program installed it with a time resolution setting of 400 ms, that’s why it works fine for 0.8 ” but not 1″ as 0.8 (but not 1) is divisible by 0.4.

    I have fixed the time resolution now to be 10 ms and it is running accurately 🙂

    Thanks so much!
    Suszie

    in reply to: 1″ does not equal 1″ #13585
    Med_Support
    Moderator
    Gary Bamberger

    Hello Suszie,

    There are a few possibilities for the problem that you are seeing:

    1. Your DIG-704 card is defective and needs to be repaired/replaced.
    2. MED-PC is not running with Real Time Priority.  If MED-PC does not have Real Time Priority, then it will lose time.
    3. You are running an older version of MED-PC and/or the DIG-704 driver and need to update.
    4. You are running in Emulation Mode.  Emulation Mode does not guarantee the timing, but it allows you to test your programs on a computer that doesn’t have hardware.

    You should contact MED Associates Support support@med-associates.com directly for help with this problem.

    Gary

    in reply to: MED PC 2 XL – not working #13512
    Med_Support
    Moderator
    Gary Bamberger

    I’m glad to hear that you figured it out. You learned more by getting it wrong the first time and then fixing it, than if you had gotten it correct the first time.

    Gary

    in reply to: DRL-4s #13524
    Med_Support
    Moderator
    Gary Bamberger

    It looks like my original code was very close. I think this might do what you want:

    S.S.2,
    S1,
      #START: ---> S2
    
    S2,
      #R^LeftLever: ---> S2  \ If we receive a responses before the timer runs out, restart the timer
      3.99":        ---> S3  \ If 3.99s passes, then reward the next lever press
    
    S3,
      #R^LeftLever: ON ^Reward ---> S4  \ 3.99 + 0.01 = 4.00s  so any response will be at 4s or later
    
    S4,
      4": OFF ^Reward ---> S2  \ After reward go back for the next 4s interval
    
    in reply to: DRL-4s #13520
    Med_Support
    Moderator
    mama6600
    S.S.2, \reset timer
    
    S1,
    #R^Leftlever: SET T = 0; Z2 ---> S2
    
    S2,
    0.01": SET T = T +0.1 ---> SX
    
    S.S.3, \If lever press occur at or passes over 4s, it will gain reward. If lever press occur before 4s, the lever press will reset the time to zero
    
    S1,
    #R^leftlever: IF T >= 4 (@True, @False)
    @Ture: ON ^Reward ---> S2
    @False: Z2 ---> SX
    
    S2,
    4" : OFF ^Reward ---> SX
    

     

    The problem is how to write a script which is describing: “If lever press occur at or passes over 4s, gain reward. If every single lever press occur before 4s (0s-3.9s), the certain lever press will reset the time to zero”.

    in reply to: DRL-4s #13516
    Med_Support
    Moderator
    Gary Bamberger

    Hello,

    It is very hard to make a suggestion without seeing the code that you have written.  Here is a possibility that might work for you:

    S.S.2,
    S1,
    #START: ---> S2
    
    S2,
    4#R1: ---> S2            \ If we receive 4 responses before the timer runs out, restart the timer
    4": ON ^Pellet ---> S3  \ If 4s passes with less than 4 responses, issue reinforcement
    
    S3,
    0.05": OFF ^Pellet ---> S2
    
    in reply to: Help modifying FR1 to a progressive ratio #13451
    Med_Support
    Moderator
    Gary Bamberger

    Hi Paul,

    Yes it is possible. Just create a list and draw from it in order using the LIST command. Every time a reward is issued draw the next value from the list.

    Gary

    in reply to: Help modifying FR1 to a progressive ratio #13449
    Med_Support
    Moderator
    Paul_K

    Hi Gary,

    Since my knowledge of the coding is very limited, is it possible to amend just the FR1 ratio in the attached code to a progressive ratio list and keep everything else the same?

    Regards, Paul.

    in reply to: Help modifying FR1 to a progressive ratio #13351
    Med_Support
    Moderator
    Gary Bamberger

    Hi Paul,

    When the program looks for an input on #R1 or in this case:

    ^LeftLever = 1
    
    S2,
    #R^LeftLever:
    

     

    It does not care if input 1 is a lever or a nosepoke.  A response on input 1 is all that is required.

    The only thing that might make a difference is if the nosepoke is in Level Mode.  If it is, then you will want to add this code to the program:

    https://mednr.com/med-nr/beam-break-release-detection-v0-1/

    It talks about beam breaks, but will work exactly the same for nose pokes in Level Mode.

     

    I hope that this information helps.
    Gary

    in reply to: Help modifying FR1 to a progressive ratio #13344
    Med_Support
    Moderator
    Paul_K

    Hi Gary,

    Our operant boxes have a nosepoke system not levers. Will that make a difference?

    Regards, Paul.

    in reply to: Help modifying FR1 to a progressive ratio #13341
    Med_Support
    Moderator
    Gary Bamberger

    Hi Paul,

    There is a progressive ratio program on our repository:

    https://mednr.com/customer-portal/medstate-notation-repository-landing-page/medstate-notation-repository-programs/

    See if that meets your needs.

     

    I hope that this information helps.
    Gary

    in reply to: Response counting during random interval #13337
    Med_Support
    Moderator
    Gary Bamberger

    Hi Suszie,

    Here is the code in question:

    S2,
    #Z^Z_PreCueFail : ADD N; SHOW 3,premature,N ;
    #Z^Z_GoCorrect : ADD W; SHOW 4,gocorrect,W ;
    #Z^Z_GoFail : ADD P; SHOW 5,gofail,P ;
    #Z^Z_NoGoCorrect : ADD Q; SHOW 6,nogocorrect,Q ;
    #Z^Z_NoGoFail : ADD R; SHOW 7,nogofail,R ;
    #Z^Z_TotalNosePokes : ADD S; SHOW 8,totalnosepokes,S ---> SX
    

    The problem is you have multiple inputs, but only one —>

    S2,
    #Z^Z_PreCueFail : ADD N; SHOW 3,premature,N ; ---> SX
    #Z^Z_GoCorrect : ADD W; SHOW 4,gocorrect,W ; ---> SX
    #Z^Z_GoFail : ADD P; SHOW 5,gofail,P ; ---> SX
    #Z^Z_NoGoCorrect : ADD Q; SHOW 6,nogocorrect,Q ; ---> SX
    #Z^Z_NoGoFail : ADD R; SHOW 7,nogofail,R ; ---> SX
    #Z^Z_TotalNosePokes : ADD S; SHOW 8,totalnosepokes,S ---> SX
    

     

    For your trial by trial data you need to zero out the previous array seal when you move it

    S.S.1,
    S1,    \Set array to increment every 2 seconds
    #START : ---> S2
    S2,
    1" : ADD T ; IF T >= 2 [@True, @False]
    @True : SET K = K+2, T = 0 ;
    SET E(K) = 0, E(K+2) = -987.987---> SX
    @False : ---> SX
    

    If you get no response, then when the program ends it will stop saving data at the first array seal.
    If you did get a response, then you would see something like -986.987 or -985.987 because you incremented the value that was already there.

     

    I hope that this information helps.
    Gary

    P.S. Please post the MPC file instead of a PDF file.  The formatting gets lost when I try to copy the text into Trans.

    in reply to: Response counting during random interval #13335
    Med_Support
    Moderator
    tyrsu

    Thanks again Gary! That fixed the random-interval generator!
    I’m still getting an error message for my SHOW logic for one particular constant – but there is no difference to any of the other constants so I have no idea what is going wrong! I tried changing the letter in case I double-booked the letter W but it’s still throwing this error message:

    ERROR # 1
    #Z^Z_PreCueFail:ADDN;SHOW3,premature,N ;#Z^Z_GoCorrect:ADDW;SHOW4,gocorrect,W ;#Z^Z_GoFail:ADDP;SHOW5,gofail,P ;#Z^Z_NoGoCorrect:ADDQ;SHOW6,nogocorrect,Q ;#Z^Z_NoGoFail:ADDR;SHOW7,nogofail,R ;#Z^Z_TotalNosePokes:ADDS;SHOW8,totalnosepokes,S —> SX
    Offending text: ^Z_GOCORRECT:ADDW
    A constant is missing ‘^’ or undeclared constant
    Can you see why? (Full code attached for more context)

    \***********************************************************
    \ Count & Display Logic
    \***********************************************************
    S.S.7, \Count and display: four totals of each response type (3-7) and total NosePokes (8)
    S1,
    #START : SHOW 3,premature,N ;
    SHOW 4,gocorrect,W ;
    SHOW 5,gofail,P ;
    SHOW 6,nogocorrect,Q ;
    SHOW 7,nogofail,R ;
    SHOW 8,totalnosepokes,S ---> S2
    S2,
    #Z^Z_PreCueFail : ADD N; SHOW 3,premature,N ;
    #Z^Z_GoCorrect : ADD W; SHOW 4,gocorrect,W ;
    #Z^Z_GoFail : ADD P; SHOW 5,gofail,P ;
    #Z^Z_NoGoCorrect : ADD Q; SHOW 6,nogocorrect,Q ;
    #Z^Z_NoGoFail : ADD R; SHOW 7,nogofail,R ;
    #Z^Z_TotalNosePokes : ADD S; SHOW 8,totalnosepokes,S ---> SX
    \*******************************************************************
    

     

    Another issue: Trial by Trial / Bin by Bin Data collection using arrays:

     

    I’m trying to use the Trial-by-Trial data collection code shared by Dave Hughes ( http://204.15.131.62/mednr/forum/index.php?topic=253.0 (http://204.15.131.62/mednr/forum/index.php?topic=253.0) ) but have been having some trouble with the data output not doing what I thought it would.

     

    I tried to simplify it down for a habituation session just monitoring nosepokes in ~2 second bins over 1 min with the house light on via this code:
    \S.S.1, – incrementing K every 2″ for the E(K) time bin array
    \S.S.2, – count nosepokes for B (totals), E(K) (time bin) array, and SHOW logic for B
    \S.S.3, – control house light and count trials (1 in this case) in B(0)

     

    \***********************************************************
    \ Inputs
    ^NosePoke = 1
    \ Outputs
    ^House = 8 \House
    \***********************************************************
    \ Variables
    \***********************************************************
    \Data Variables
    \B() = Totals
    \B(0) = Total number of Trials (determined by how many ITIs have been)
    \B(1) = Total number of NosePokes
    
     
    
    \E() = Time bin data
    \E(K) = Not used
    \E(K+1) = #R^NosePoke
    
     
    
    \T = time counter for E(K)
    
     
    
    DIM E = 100
    DIM B = 2
    
     
    
    \***********************************************************
    \ Trial Logic
    \***********************************************************
    S.S.1,
    S1, \Set array to increment every 2 seconds
    #START : ---> S2
    S2,
    1" : ADD T ; IF T >= 2 [@True, @False]
    @True : SET K = K+2, T = 0 ;
    SET E(K+2) = -987.987---> SX
    @False : ---> SX
    S.S.2,
    S1, \Show total # nosepokes and count nosepokes into B(1) total
    \and E(K) second-by-second arrays
    #START : SHOW 1,nosepokes,B(1) ---> S2
    S2,
    #R^NosePoke : ADD B(1), E(K+1) ; SHOW 1,nosepokes,B(1) ---> SX
    S.S.3, \count a trial and turn on lights for 10 minutes then turn off and save data
    S1,
    #START : ON ^House ;
    ADD B(0) ---> S2
    S2,
    1' : OFF ^House ---> STOPABORTFLUSH
    ********************************************************************
    

    I don’t get any error messages and the B (totals) output is fine, but the data comes out with nothing in the E() output.
    Can you see what I am doing wrong?

     

    Thank you Gary – I really appreciate your help!
    Suszie

    in reply to: Recording data into Arrays #13348
    Med_Support
    Moderator
    Gary Bamberger

    Unfortunately it is not.  The DISKCOLUMNS command affects all data arrays the same.

    What I have done in the past is to create the array so that certain data elements are left empty:

    \ C() = Array 1
    \ C(I)   = Trial #
    \ C(I+1) = Data 1
    \ C(I+2) = Data 2
    \ C(I+3) = Data 3
    \ C(I+4) = Data 4
    \ C(I+5) = Data 5
    \ C(I+6) = Data 6
    
    \ D() = Array 2
    \ D(J)   = Trial #
    \ D(J+1) = Data 1
    \ D(J+2) = Data 2
    \ D(J+3) = Data 3
    \ D(J+4) = Data 4
    \ D(J+5) = Not Used
    \ D(J+6) = Not Used
    

     

    I hope that this helps.
    Gary

    in reply to: Response counting during random interval #13333
    Med_Support
    Moderator
    Gary Bamberger

    Hi Suszie,

    I have to apologize.  My last post had a bug in the code.  Here is the code in question:

     

    S5,     \Initiate random time selected from List M (6-21")move on to S6
    1" : SET T = T+1;
    RANDD X = M ---> S6
    
    S6,     \Count NosePokes - register both Pre-Cue NosePokesand for total #NosePokes
    M#T : ---> S7
    #R^NosePoke : Z^Z_PreCueNosePoke ;
    Z^Z_TotalNosePokes ---> SX
    

     

    In S5 we randomly drew a value from LIST M.  We now want to use that value which is in the variable X.  We need to use X in the timed input statement instead of M:

     

    S6,     \Count NosePokes - register both Pre-Cue NosePokesand for total #NosePokes
    X#T : ---> S7
    #R^NosePoke : Z^Z_PreCueNosePoke ;
    Z^Z_TotalNosePokes ---> SX
    

     

    There is also a bug in S.S.6, S1:

     

    S1,     \ Wait for ITI Cue
    0.001" : SET E(K+12) = -987.987 ;
    SET F(G+11)= -987.987 ;
    SET D(J+9) = -987.987 ;
    SET B() = -987.987 ---> SX
    

     

    There is no subscript in the () for the B array.  Since B is only 11 elements long I would just remove it:

     

    S1,     \ Wait for ITI Cue
    0.001" : SET E(K+12) = -987.987 ;
    SET F(G+11)= -987.987 ;
    SET D(J+9) = -987.987 ---> SX
    

     

    Gary

    in reply to: Response counting during random interval #13330
    Med_Support
    Moderator
    tyrsu

    Thank you so much Gary! It is now throwing me this error message:

    "ERROR # 5
    M#T:--->S7
    Offending text: M
    Attempt to use an array variable without a subscript or undeclared constant"
    

    I have defined List M under the variables – is there somewhere else I need to declare it?

    Problem 2:
    I’m also really struggling with defining my arrays – I keep getting error messages like:
    “Attempt to use a variable as an array without declaration via DIM or LIST”

    It appears I am not declaring the array variables properly – but unfortunately I can’t find any insight into what I am doing wrong in the programmer’s manual. Is it obvious to you where I am going wrong? (whole program attached)

    Background info:
    Basically all I need is a second-by-second read out of my Z-pulses and the NosePokes (Input 1) which I have tried to code into the array E(K) (counted in S.S.6,).

    For convenience I have aso tried to add arrays to calculate trial-by-trial data for nose-pokes in each period and the response outcomes in D(J), as well as an array to collect my totals in B() – (these are both also counted in S.S.6,), and finally an array to collect trial-by-trial data of the latency until first nosepoke and period duration for each of the trial periods (pre-cue, cue, reward, ITI) in array F(G) (collected in S.S.2,).

    S.S.1, – Trial logic
    S.S.2, – Latency to first response & Period Duration for F(G) data collection
    S.S.3, – Increment Time Bin array every 0.2″ for E(K) data collection
    S.S.4, – Increment Latency & Duration array at the beginning of every trial for F(G) data collection
    S.S.5, – Increment Response/Nosepoke array at the beginning of every trial for D(J) data collection
    S.S.6, – Data collection for totals B(), time bin E(K), and trial by trial response D(J) data
    S.S.7, – Count and Display Logic
    S.S.8, – Session end by MaxTrials logic
    S.S.9, – Session end by MaxDuration logic

    It may just be that I am making it too complicated – do you think I should just stick to one second-by-second array counting all my nosepokes and Z pulses and then transfer the data to Matlab or somewhere to bin it by trial and time-stamps?

    Thank you so much for your time, Gary!
    Suszie

    in reply to: Delayed reward task #12510
    Med_Support
    Moderator
    Aude

    I also copy here the data file by just running the task for couple of sec (not even start a trial). It was just for you to see the Array A:

     

    File: C:\MED-PC IV\DATA\!2017-07-20
    
    
    
    
    
    
    
    Start Date: 07/20/17
    End Date: 07/20/17
    Subject: 0
    Experiment: 0
    Group: 0
    Box: 1
    Start Time: 10:22:29
    End Time: 10:22:46
    MSN: Delay discounting
    A:
     0: 10.00 15.00 13.00 0.00 4.00 5.00 2.00 12.00 1.00
     9: 1000.00 1500.00
    B:
     0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
    C:
     0: 0.50
    D:
     0: 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
    E:
     0: 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

     

     

    Thank you very much for your help,

     

    best
    aude

    in reply to: Delayed reward task #12507
    Med_Support
    Moderator
    Aude

    Dear Gary,

     

    Here is the entire code, with the changes I made following your recommendations.
    I left the the ^nosepoke input in level mode finally

     

    \ Inputs
    ^ImmediateLever  = 1 \Left lever                                                                                    
    ^DelayedLever = 2 \Right lever       
    ^Nosepoke   = 3  \ Level Mode
    
    
    
    \ Outputs                               
    ^ImmediateLever  = 13  \ left lever
    ^DelayedLever = 15 \ Right lever 
    ^Pellet     = 3
    ^StimLight  = 4
    ^HouseLight = 7
    ^fan = 1             
    
    
    
    \ A() = Control Variables with Assigned Aliases as Defined
    Var_Alias New Trial Interval (sec)                      = A(0)  \ Default = 100 seconds
    Var_Alias Response Time (sec)                           = A(1)  \ Default = 10 seconds
    Var_Alias Immediate Reward Lever (15=Left  13=Right)      = A(2)  \ Default = 15-Left
    Var_Alias Delayed Reward Lever (15=Left  13=Right)        = A(3)  \ Default = 13-Right
    Var_Alias Number of Pellets for Delayed Rewards         = A(4)  \ Default = 4
    Var_Alias Number of Blocks to Run                       = A(5)  \ Default = 5
    Var_Alias Number of Forced Trials (Should be an Even #) = A(6)  \ Default = 2
    Var_Alias Number of Trials per Block                    = A(7)  \ Default = 12
    Var_Alias SoftCR Data Array (1=Yes  0=No)               = A( \ Default = 1
    
    
    
    ^NTI            = 0
    ^ResponseTime   = 1
    ^ImmediateLever = 2
    ^DelayedLever   = 3
    ^LargeReward    = 4
    ^NumBlocks      = 5
    ^ForcedTrials   = 6
    ^TrialsPerBlock = 7
    ^SoftCR         = 8
    ^NTITicks       = 9
    ^ResponseTicks  = 10
    
    
    
    
    
    \ List Data Variables Here
    \  B() = Experiment Totals
    \  B(0) = Not Used
    \  B(1) = Total Pellets Delivered
    \  B(2) = Total Immediate Lever Responses
    \  B(3) = Total Delayed   Lever Responses
    \  B(4) = Total Successful Trials
    \  B(5) = Total Nose Poke Omissions        (Type 1)
    \  B(6) = Total Lever Omissions            (Type 2)
    \  B(7) = Total Delayed Reward Omissions   (Type 3)
    \  B( = Total Immediate Reward Omissions (Type 4)
    \
    \  C() = SoftCR Array
    \
    \  D() = Trial by Trial Data
    \  D(J)   = Trial Number in this Block
    \  D(J+1) = Number of Pellets Delivered this Trial
    \  D(J+2) = Lever Chosen (1=Immediate, 2=Delayed)
    \  D(J+3) = Omission Type (1, 2, 3, or 4)
    \  D(J+4) = Trial Completed Successfully (1=Yes, 0=No)
    \  D(J+5) = Latency to Initial Nose Poke
    \  D(J+6) = Latency to Lever Press
    \  D(J+7) = Latency to Final Nose Poke
    \  D(J+8) = Delay Time to Reward
    \
    \  E() = Block by Block Data
    \  E(K)   = Block Number
    \  E(K+1) = Number of Pellets Delivered this Block
    \  E(K+2) = Number of Immediate Lever Responses this Block
    \  E(K+3) = Number of Delayed   Lever Responses this Block
    \  E(K+4) = Number of Successful Trials this Block
    \  E(K+5) = Number of Nose Poke Omissions        (Type 1) this Block
    \  E(K+6) = Number of Lever Omissions            (Type 2) this Block
    \  E(K+7) = Number of Delayed Reward Omissions   (Type 3) this Block
    \  E(K+8) = Number of Immediate Reward Omissions (Type 4) this Block
    
    
    
    
    
    \ List Working Variables Here
    \  F = Counter for Nose Poke Level Inputs
    \  G = List for selecting the Forced Trial Type
    \  H = Forced Trial Type (Immediate or Delayed) drawn from List G
    \  I = Subscript for the SoftCR Array C
    \  J = Subscript into the Trial Array D
    \  K = Subscript into the Block Array E
    \  L = Block Number
    \  M = Trial Number this Block
    \  N = List of Delay Times
    \  O = Nose Poke Latency Timer
    \  P = Lever Latency Timer
    \  Q = Number of Pellets to Deliver
    \  R = Number of Rewards Delivered
    \  S = Subscript into List N
    \  T = Elapsed Time in 0.01 sec increments for SoftCR Data
    \  U = Delay Time that was drawn from List N
    
    
    
    
    
    LIST G = 1, 2                    \ Forced Trial Type
    LIST N = 0", 10", 20", 40", 60"  \ List of Delay Times
    
    
    
    DIM A = 10
    DIM B = 8
    DIM C = 100000  \ Dimension Array C for 100,001 data points.
                    \ Under MED-PC Version IV, this array may be
                    \ enlarged up to 1 million elements; however,
                    \ 100,001 was felt to be adequate for this application.
                    \ An end of array seal -987.987 will limit the saved
                    \ file to only those elements used during the running
                    \ of the procedure.
    DIM D = 50000
    DIM E = 1000           
    DIM V = 1
               
    \ Z-Pulses Used in this Program
    ^Z_Pellet      = 1   \ Signal Pellet Delivery
    ^Z_NPLat       = 2   \ Signal Start of Nose Poke Latency Counter
    ^Z_LeverLat    = 3   \ Signal Start of Lever Latency Counter
    ^Z_LatEnd      = 4   \ Signal End of Latency Counters
    ^Z_PelletEnd   = 5   \ Signal End of Pellet Deliveries
    ^Z_NewTrial    = 6   \ Signal New Trial
    ^Z_CorrectResp = 7   \ Signal a Step or Correct Response
    ^Z_Reward      = 8   \ Signal a Pip or Reward Issued
    ^Z_Type1       = 9   \ Signal a Event 0 or Type 1 Omission
    ^Z_Type2       = 10  \ Signal a Event 1 or Type 2 Omission
    ^Z_Type3       = 11  \ Signal a Event 2 or Type 3 Omission
    ^Z_Type4       = 12  \ Signal a Event 3 or Type 4 Omission
    ^Z_NPBreak     = 13  \ Signal Completed Nose Poke Break
    ^Z_NPRelease   = 14  \ Signal Nose Poke Withdrawal
    
    
    
    
    
    DISKCOLUMNS = 9
    DISKFORMAT  = 10.2
    DISKVARS    = A, B, C, D, E
    
    
    
    
    
    \***************************************************
    \            DELAYED REWARD_V2 SCHEDULE
    \ S1 - Set Default Values
    \   New Trial Interval                    (100 sec)
    \   Response Time                         (10 sec)
    \   Immediate Reward Lever                (1-Left)
    \   Delayed Reward Lever                  (2-Right)
    \   Number of Pellets for Delayed Rewards (4)
    \   Number of Blocks to Run               (5)
    \   Number of Forced Trials               (2)
    \   Number of Trials per Block            (12)
    \   SoftCR Data Array                     (1-Yes)
    \***************************************************
    S.S.1,
    S1,
      0.01": SET A(^NTI)          = 100, A(^ResponseTime)   = 10, A(^ImmediateLever) = 13;
             SET A(^DelayedLever) = 15,   A(^LargeReward)    = 4,  A(^NumBlocks)      = 5;
             SET A(^ForcedTrials) = 2,   A(^TrialsPerBlock) = 12, A(^SoftCR)         = 1 ---> S2
    
    
    
    S2,     \ First Statement: Wait for START signal, initialize the Trial
            \ number and the Block number, and transition to ITI.
            \
            \ Second Statement:  Update screen display with default values
            \ for control variables.  This will show any changes made via
            \ the Configure | Change Variables window prior to START.
      #START: CLEAR 1,60; SET L = 1, M = 1;
              RANDD H = G; LIST U = N(S);
              SET D(J+9) = -987.987, E(K+9) = -987.987;
              SET A(^NTITicks)      = A(^NTI)          * 1";
              SET A(^ResponseTicks) = A(^ResponseTime) * 1";
              if A(^ImmediateLever)= 13 [@Left, @Right]
                  @Left: set v(0)=1, v(1)=2 ---> S3
                  @Right: set v(0)=2, v(1)=1  ---> S3
                  
      1": SHOW 1,New Trial Int,A(^NTI),          2,Response Time,A(^ResponseTime),  3,Immediate Lever,A(^ImmediateLever);
          SHOW 4,Delayed Lever,A(^DelayedLever), 5,# of Pellets,A(^LargeReward),    6,# of Blocks,A(^NumBlocks);
          SHOW 7,Forced Trials,A(^ForcedTrials), 8,Trials/Block,A(^TrialsPerBlock), 9,SoftCR Code,A(^SoftCR) ---> SX
    
    
    
    S3,     \ Time Initial ITI.  Signal start of Nose Poke Latency counter.
      #Z^Z_NewTrial: ON ^HouseLight, ^StimLight;
                     SET E(K) = L, D(J) = M;
                     Z^Z_NPLat ---> S4
    
    
    
    S4,     \ If Nose Poke is made within allotted time, turn off
            \ the Stim Light and extend only one lever if a
            \ forced trial or both levers if a free choice trial.
            \ Signal start of Lever Latency counter.
            \
            \ If Timeout, record Type 1 Omission.
      #Z^Z_NPBreak: OFF ^StimLight; SET D(J+5) = O;
                    Z^Z_LeverLat; Z^Z_LatEnd; Z^Z_CorrectResp;
                    IF M > A(^ForcedTrials) [@Free, @Forced]
                       @Free: ON A(^ImmediateLever), A(^DelayedLever) ---> S5
                       @Forced: IF H = 1 [@Immediate, @Delayed]
                                   @Immediate: ON A(^ImmediateLever) ---> S5
                                   @Delayed:   ON A(^DelayedLever)   ---> S5
      A(^ResponseTicks)#T: OFF ^HouseLight, ^StimLight;
                           ADD B(5), E(K+5);
                           SET D(J+3) = 1, D(J+5) = O;
                           Z^Z_LatEnd; Z^Z_Type1 ---> S10
    
    
    
    S5,     \ If Lever response is made within allotted time, turn off
            \ the House Light, retracts the levers.  Signal to issue
            \ immediate rewards.
            \
            \ If Timeout, record Type 2 Omission.
      #Rv(0): ADD B(2), E(K+2); ON ^StimLight;
                            OFF ^HouseLight, A(^ImmediateLever), A(^DelayedLever);                                                 
                            SET D(J+2) = 1, D(J+6) = P, Q = 1;
                            Z^Z_Pellet; Z^Z_NPLat;                                
                            Z^Z_LatEnd; Z^Z_CorrectResp ---> S6
      #Rv(1): ADD B(3), E(K+3);                                                         
                          OFF ^HouseLight,  A(^ImmediateLever), A(^DelayedLever);
                          SET D(J+2) = 2, D(J+6) = P, Q = A(^LargeReward);
                          Z^Z_LatEnd; Z^Z_CorrectResp ---> S7
      A(^ResponseTicks)#T: OFF ^HouseLight, A(^ImmediateLever), A(^DelayedLever);
                           ADD B(6), E(K+6);
                           SET D(J+3) = 2, D(J+6) = P;
                           Z^Z_LatEnd; Z^Z_Type2 ---> S10
    
    
    
    S6,     \ Immediate Reward Lever chosen.  If Nose Poke detected
            \ record latency.
            \
            \ If timeout record Type 4 Omission.
      #Z^Z_NPBreak: OFF ^HouseLight, ^StimLight;
                    ADD B(4), D(J+4), E(K+4);
                    SET D(J+7) = O;
                    Z^Z_LatEnd; Z^Z_CorrectResp ---> S10
      A(^ResponseTicks)#T: OFF ^HouseLight, ^StimLight;
                           ADD B( , E(K+8);
                           SET D(J+3) = 4, D(J+7) = O;
                           Z^Z_LatEnd; Z^Z_Type4 ---> S10
    
    
    
    S7,     \ Delayed Reward Lever chosen.  Wait until delay time
            \ has elapsed, signal for the large reward to be
            \ issued, and turn on the Stim Light.
      U#T: ON ^StimLight; SET D(J+8) = U;
           Z^Z_Pellet; Z^Z_NPLat ---> S8
    
    
    
    S8,     \ If Nose Poke detected record latency.  If Z^Z_PelletEnd
            \ pulse arrives, last pellet has been issued, begin timer.
      #Z^Z_NPBreak: OFF ^HouseLight, ^StimLight;
                    ADD B(4), D(J+4), E(K+4);
                    SET D(J+7) = O;
                    Z^Z_LatEnd; Z^Z_CorrectResp ---> S10
      #Z^Z_PelletEnd: ---> S9
    
    
    
    S9,     \ If Nose Poke detected record latency.
            \
            \ If timeout record Type 3 Omission.
      #Z^Z_NPBreak: OFF ^HouseLight, ^StimLight;
                    ADD B(4), D(J+4), E(K+4);
                    SET D(J+7) = O;
                    Z^Z_LatEnd; Z^Z_CorrectResp ---> S10
      A(^ResponseTicks)#T: OFF ^HouseLight, ^StimLight;
                           ADD B(7), E(K+7);
                           SET D(J+3) = 3, D(J+7) = O;
                           Z^Z_LatEnd; Z^Z_Type3 ---> S10
    
    
    
    S10,    \ Wait for New Trial Signal.  Increment trial number.
            \ Select next lever for forced trials.  If this is the
            \ 12th trial in this block, increment the block number,
            \ select new Delay value, and reset trial number to 1.
            \ Signal start of Nose Poke Latency counter.
      #Z^Z_NewTrial: ADD M; RANDD H = G;
                     IF M > A(^TrialsPerBlock) [@NewBlock, @Cont]
                        @New: LIST U = N(S); ADD L;
                              IF L > A(^NumBlocks) [@End, @Cont]
                                 @End: ---> S11
                                 @Cont: SET K = K + 9, E(K+9) = -987.987;
                                        SET M = 1, J = J + 9, D(J+9) = -987.987;
                                        ON ^HouseLight, ^StimLight;
                                        SET E(K) = L, D(J) = M; Z^Z_NPLat ---> S4
                        @Cont: SET J = J + 9, D(J+9) = -987.987;
                               ON ^HouseLight, ^StimLight;
                               SET D(J) = M; Z^Z_NPLat ---> S4
    
    
    
    S11,    \ Wait for Screen Update and end with
            \ STOPABORTFLUSH for Automatic Data Saving
      2": OFF ^fan ---> STOPABORTFLUSH
    
    
    
    
    
    \***************************************************
    \               REWARD CONTROL TIMER
    \***************************************************
    S.S.2,
    S1,
      #Z^Z_Pellet: ON ^Pellet; ADD B(1), D(J+1), E(K+1);
                   Z^Z_Reward ---> S2
    
    
    
    S2,     \ Time Reward Device for 0.05 seconds
      0.05": OFF ^Pellet; ADD R;
             IF R >= Q [@Done, @Cont]
                @Done: SET R = 0; Z^Z_PelletEnd ---> S1
                @Cont: ---> S3
    
    
    
    S3,
      0.45": ON ^Pellet; ADD B(1), D(J+1), E(K+1);
             Z^Z_Reward ---> S2
    
    
    
    
    
    \***************************************************
    \     INCREMENT TIME T FOR IRT AND EVENT ARRAY
    \***************************************************
    S.S.3,  \ 10ms Resolution.  Every 10ms = 1 Tick
    S1,
      #START: IF A(^SoftCR) > 0 [] ---> S2
    
    
    
    S2,
      0.01": ADD T ---> SX
    
    
    
    
    
    \*********************************************************
    \ ADD A STEP ELEMENT TO ARRAY C FOR EACH CORRECT RESPONSE
    \*********************************************************
    S.S.4,  \ Enter each Response into Array C.
            \ This code is for Relative or Incremental
            \ values.  If Absolute or Cumulative values are
            \ desired, delete the code ", T = 0" in S2.
    S1,
      #START: IF A(^SoftCR) > 0 [@ActivateSoftCR, @NoSoftCR]
                 @ActSoftCR: SET C(I) = 0.50, I = I + 1, C(I) = -987.987 ---> S2
                 @NoSoftCR:  SET C(0) = -987.987 ---> SX  \ Seal Array
    
    
    
    S2,
      #Z^Z_CorrectResp: SET C(I) = T + 0.10, T = 0; ADD I;
                        IF I = 100000 [@True, @False]
                           @True: ---> S1
                           @False: SET C(I) = -987.987 ---> SX
    
    
    
    
    
    \***************************************************
    \   ADD A PIP ELEMENT TO ARRAY C FOR EACH REWARD
    \***************************************************
    S.S.5,  \ Enter each Reward into Array C.
            \ This code is for Relative or Incremental
            \ values.  If Absolute or Cumulative values are
            \ desired, delete the code ", T = 0" in S2.
    S1,
      #START: IF A(^SoftCR) > 0 [] ---> S2
    
    
    
    S2,
      #Z^Z_Reward: SET C(I) = T + 0.20, T = 0; ADD I;
                   IF I = 100000 [@True, @False]
                      @True: ---> S1
                      @False: SET C(I) = -987.987 ---> SX
    
    
    
    
    
    \************************************************************
    \ ADD AN EVENT 0 ELEMENT TO ARRAY C FOR EACH TYPE 1 OMISSION
    \************************************************************
    S.S.6,  \ Enter each Type 1 Omission into Array C.
    S1,
      #START: IF A(^SoftCR) > 0 [] ---> S2
    
    
    
    S2,
      #Z^Z_Type1: SET C(I) = T + 0.60, C(I+1) = 0.50, T = 0, I = I + 2;
                  IF I >= 100000 [@True, @False]
                     @True: ---> S1
                     @False: SET C(I) = -987.987 ---> SX
    
    
    
    
    
    \************************************************************
    \ ADD AN EVENT 1 ELEMENT TO ARRAY C FOR EACH TYPE 2 OMISSION
    \************************************************************
    S.S.7,  \ Enter each Type 2 Omission into Array C.
    S1,
      #START: IF A(^SoftCR) > 0 [] ---> S2
    
    
    
    S2,
      #Z^Z_Type2: SET C(I) = T + 0.61, C(I+1) = 0.51, T = 0, I = I + 2;
                  IF I >= 100000 [@True, @False]
                     @True: ---> S1
                     @False: SET C(I) = -987.987 ---> SX
    
    
    
    
    
    \************************************************************
    \ ADD AN EVENT 2 ELEMENT TO ARRAY C FOR EACH TYPE 3 OMISSION
    \************************************************************
    S.S.8,  \ Enter each Type 3 Omission into Array C.
    S1,
      #START: IF A(^SoftCR) > 0 [] ---> S2
    
    
    
    S2,
      #Z^Z_Type3: SET C(I) = T + 0.62, C(I+1) = 0.52, T = 0, I = I + 2;
                  IF I >= 100000 [@True, @False]
                     @True: ---> S1
                     @False: SET C(I) = -987.987 ---> SX
    
    
    
    
    
    \************************************************************
    \ ADD AN EVENT 3 ELEMENT TO ARRAY C FOR EACH TYPE 4 OMISSION
    \************************************************************
    S.S.9,  \ Enter each Type 4 Omission into Array C.
    S1,
      #START: IF A(^SoftCR) > 0 [] ---> S2
    
    
    
    S2,
      #Z^Z_Type4: SET C(I) = T + 0.63, C(I+1) = 0.53, T = 0, I = I + 2;
                  IF I >= 100000 [@True, @False]
                     @True: ---> S1
                     @False: SET C(I) = -987.987 ---> SX
    
    
    
    
    
    \***************************************************
    \             NOSE POKE LATENCY COUNTER
    \***************************************************
    S.S.10, \ 10ms Resolution
    S1,
      #Z^Z_NPLat: SET O = 0.01 ---> S2
    
    
    
    S2,
      0.01": SET O = O + 0.01 ---> SX
      #Z^Z_LatEnd: ---> S1
    
    
    
    
    
    \***************************************************
    \               LEVER LATENCY COUNTER
    \***************************************************
    S.S.11, \ 10ms Resolution
    S1,
      #Z^Z_LeverLat: SET P = 0.01 ---> S2
    
    
    
    S2,
      0.01": SET P = P + 0.01 ---> SX
      #Z^Z_LatEnd: ---> S1
    
    
    
    
    
    \***************************************************
    \              TIME NEW TRIAL INTERVAL
    \***************************************************
    S.S.12, \ Times the New Trial Interval.  A new trial
            \ is started every A(^NTI) seconds regardless
            \ of the responses that the animal has done.
    S1,
      #START: ---> S2
    
    
    
    S2,
      A(^NTITicks)#T: Z^Z_NewTrial ---> S2
    
    
    
    
    
    \***************************************************
    \   NOSE POKES DEFINED - 20ms BREAK, 20ms RELEASE
    \***************************************************
    S.S.13, \ Nose Poke Defined - 20ms Break, 20ms Release.
    S1,
      #Z^Z_NPLat: ---> S2
    
    
    
    S2,     \ Inputs in Level Mode generate an input "count" on each
            \ interrupt.  With a 10 ms system resolution 2 counts
            \ will be reached in 20 ms.  The Z^Z_NPBreak pulse is used to
            \ signal a completed Beam Break.  The second statement resets
            \ the counter every 20 ms so that a partial Beam Break of
            \ less than 20 ms will not constitute a Response.
      #R^NosePoke: ADD F; IF F >= 2 [@BeamBreak, @NoBeamBreak]
                             @Break: SET F = 0; Z^Z_NPBreak ---> S3
                             @NoBreak: ---> SX
      0.02": SET F = 0 ---> S2
    
    
    
    S3,     \ As long as the Beam is broken the second statement
            \ causes a re-entry to this State.  This resets the
            \ the internal 20 ms timer so it never times out.  When
            \ the Beam is released for 20 ms the timer times out
            \ and a Z^Z_NPRelease pulse signals the release.
      0.02": Z^Z_NPRelease ---> S1
      #R^NosePoke: ---> S3
    
    
    
    
    
    \***************************************************
    \                  UPDATE DISPLAY
    \***************************************************
    S.S.14,
    S1,
      #START: SHOW 1,Tot Pellets,B(1),      2,Immed Lvr Presses,B(2), 3,Delay Lvr Presses,B(3);
              SHOW 4,Completed Trials,B(4), 5,Tot Type 1,B(5),        6,Tot Type 2,B(6);
              SHOW 7,Tot Type 3,B(7),       8,Tot Type 4,B( ;
              SHOW 11,Block #,L,            12,Trial #,M,             13,Delay,U/1" ---> S2
    
    
    
    S2,
      1": SHOW 1,Tot Pellets,B(1),      2,Immed Lvr Presses,B(2), 3,Delay Lvr Presses,B(3);
          SHOW 4,Completed Trials,B(4), 5,Tot Type 1,B(5),        6,Tot Type 2,B(6);
          SHOW 7,Tot Type 3,B(7),       8,Tot Type 4,B( ;
          SHOW 11,Block #,L,            12,Trial #,M,             13,Delay,U/1" ---> S2
    
    
    
    \***************************************************
    \                  START FAN
    \***************************************************
    S.S.15,
    S1,
      #START: ON ^fan ---> SX
Viewing 33 posts - 1 through 33 (of 305 total)