Classical conditioning program help

MEDState Notation Repository Forums Coding Help Archive Classical conditioning program help

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #12557
    Med_Support
    Moderator
    sharmalab007

    Hi,
    I am trying to figure out this program (attached) that I plan to use for classical conditioning in mice using a MED-PC operant chamber.
    The program is as follows : 10 s precue, 10 s cue (sound), 10 s post cue, variable ITI ranging from 60 to 180 s; 12 trials per session.
    2700Hz, 85dB, 10 sec tone

    I have also attached an output from the run.
    My questions are as follows:
    a) Why is DIMH=31 and DIMZ=5000 ( I know DIM H is to hold HE data but where is it in the output?) What is DIM Z for? What is LIST B ?

    b) What is the event index?
    c) Where do i see data for parameters listed under DIM D?
    d) Under SS1> S1 what is SET o=5 and SET l=12000 for? My understanding is that the duration is 10 sec for the cue, but then where does 12000 come from?
    e) Under SS1>S1 how do you interpret the code D(time)=D (time) +0.1
    show 1, session time, d (time)/60—> S2 OR

    Can someone interpret what the steps mean for SS1 to SS9 and if the output attached makes any sense.

    Any help would be appreciated!

    Thanks

    Suraj

    MasterPavlovianntpd

    21st october pavlov trialdata

    #12558
    Med_Support
    Moderator
    Gary Bamberger

    Hello Suraj,

    Let’s see if I can answer some of your questions.

    A)
    The H Array is probably the most difficult to explain.  It is being filled with the number of Head Entries that happened at various times since the Trials were started:

    H(0)  = Total Responses Recorded
    H(1)  = Responses that took longer than 30s
    H(2)  = Number of Head Entries that happened between 0.0 - 1.0s after the Trial started
    H(3)  = Number of Head Entries that happened between 1.1 - 2.0s after the Trial started
    H(4)  = Number of Head Entries that happened between 2.1 - 3.0s after the Trial started
         ...
    H(29) = Number of Head Entries that happened between 27.1 - 28.0s after the Trial started
    H(30) = Number of Head Entries that happened between 28.1 - 29.0s after the Trial started
    H(31) = Number of Head Entries that happened between 29.1 - 30.0s after the Trial started
    

    It is dimensioned to be 32 (0-31) elements long because that is the size required to hold all of the possible Head Entries times that happen during the 30s Trial Length (10s PreCue, 10s Cue, 10s PostCue).

    Here is the data in the H array from the file that you sent:

    H:
    0:        0.000        0.000        0.000        0.000        0.000
    5:        0.000        0.000        0.000        0.000        0.000
    10:        0.000        0.000        0.000        0.000        0.000
    15:        0.000        0.000        0.000        0.000        0.000
    20:        0.000        0.000        0.000        0.000        0.000
    25:        0.000        0.000        0.000        0.000        0.000
    30:        0.000        0.000
    

    It looks like you had no responses.  In the program the Head Entry is on Input 6.  There are several possibilities as to why there were no responses recorded:

    1) The Head Entry input is not currently connected to Input 6.  It could be connected to a different input or not connected at all.

    2) The MED-PC Hardware Configuration file is setup incorrectly and Input 6 is not mapped to the Head Entry detector.

    3) The hardware is setup correctly and functioning correctly, but in this experiment there were no Head Entry inputs detected.

    The fact that the Z Array is Dimensioned to 5001 (0-5000) elements is an arbitrary choice.  I’m sure it was chosen because that is larger than all of the possible data that the program will generate.  It is a good practice to create the arrays larger than needed because if in the future the number of Trials is changed, then the array will still be large enough to contain all of the data.

    LIST B helps decides if a Trial where the Animal responds correctly during the Cue is to be rewarded.  A value is drawn from LIST B at the beginning of a Trial.  If the value drawn is a 1, and the Animal responds correctly during the Cue, then the Animal is rewarded for the correct response.  If the value drawn is a 0, and the Animal responds correctly during the Cue, then the Animal is NOT rewarded for the correct response.

    B)
    The Event Index is a record of the times that various things happened during the Trial.  The number before the decimal point is the time of the event.  The number after the decimal point is the event that happened.  Here is the meaning of the numbers after the data point.

    .1 = Head Entry
    .2 = Start of 10s PreCue or Trial Start
    .3 = Start of 10s Cue
    .4 = Start of 10s PostCue
    .5 = End   of 10s PostCue or Trial End
    .6 = Pellet Reward was issued

    Here is the values that were recorded in your data file:

    Z:
    0:     1800.200     1900.300     2000.400     2100.500     3300.200
    5:     3400.300     3500.400     3600.500     5100.200     5200.300
    10:     5300.400     5400.500     6000.200     6100.300     6200.400
    15:     6300.500     7200.200     7300.300     7400.400     7500.500
    20:     8700.200     8800.300     8900.400     9000.500    10800.200
    25:    10900.300    11000.400    11100.500    12600.200    12700.300
    30:    12800.400    12900.500    13800.200    13900.300    14000.400
    35:    14100.500    14701.200    14801.300    14901.400    15001.500
    40:    15901.200    16001.300    16101.400    16201.500    17701.200
    45:    17801.300    17901.400    18001.500
      • The 1st number says that at 180s (1800 / 10) since the Session was started the 1st Trial or PreCue (.2) was started.

     

      • The 2nd number says that at 190s (1900 / 10) since the Session was started the Cue (.3) was turned on.

     

      • The 3rd number says that at 200s (2000 / 10) since the Session was started the Cue (.4) was turned off and the PostCue now begins.

     

      • The 4th number says that at 210s (2100 / 10) since the Session was started the 1st Trial or PostCue (.5) ended.

     

     

    Why is the number divided by 10.  Because of the following program code:
    
      S.S.8,  \ Event Timer
      S1,
        #START: ---> S2
    
      S2,
        0.1": ADD P(^Event_Time) ---> S2
    
    Every 0.1" or 100ms P(^Event_Time) is incremented.  100ms * 10 = 1s.  So to convert the numbers to seconds you need to divide the value by 10.
    
    

    C)
    The D Array is definied as follows:

    DIM D = 10
    ^Time           = 0  \\session timer
    ^Trial          = 1
    ^ITI_time       = 2
    ^ITI_HE         = 3
    ^ITIHE_rate     = 4
    ^preCUE_HE      = 5
    ^preCUE_rate    = 6
    ^cue_HE         = 7
    ^cueHE_rate     = 8
    ^postcue_HE     = 9
    ^postcueHE_rate = 10
    

    And here is the values from the data file that you sent:

    D:
         0:     1830.100       12.000     1469.900        0.000        0.000
         5:        0.000        0.000        0.000        0.000        0.000
        10:        0.000
    

    I’ve added an explanation for the data elements below:

    D:                                                               Rate of HE
    Number of   Responses
    Time Spent    Head Entries  During the
    Session Time   Trials Run    in ITI       During ITI      ITI
    0:     1830.100       12.000     1469.900        0.000        0.000

    Rate of HE                Rate of HE
    Number of    Responses   Number of     Responses   Number of
    Head Entries   During the  Head Entries  During the  Head Entries
    During PreCue   PreCue     During Cue      Cue       During PostCue
    5:        0.000        0.000        0.000        0.000        0.000

    Rate of HE
    Responses
    During the
    PostCue
    10:        0.000

    Values 4-10 are 0 because there were no Head Entries Recorded.

    D)
    The Set O = 5 is being used to set the Rise/Fall Time to 5ms.  The reason for the Rise/Fall time is to prevent popping and/or clicking sounds when a Tone is turned on.  If you try to go from 0dB to 85dB too quickly, then the speaker will not be able to handle it and you could hear popping and/or clicking sounds instead of the desired Pure Tone so the time is set to allow to speaker to go from 0dB to 85dB in 5ms.

    The SET L = 12000 is being used to set the duration to 12000ms or 12s.  The desired Tone length of 10s and is really controlled by the ToneOn and ToneOff commands.  Setting the default duration to 12s is either a holdover from a previous program or as a failsafe to make sure the Tone doesn’t run indefinitely.

    E)
    The Named Constant ^Time is set to 0 (^Time = 0) before State Set 1.  So D(^Time) is really D(0).  The code in question:

    S2,
    0.1″: SET D(^Time) = D(^Time) + 0.1;
    SHOW 1,SessionTime,D(^Time)/60 —> S2

    Is your Session Timer.  Every 100ms or 0.1″ the program is adding 0.1 to the value in D(0).  It is then displaying that time to the screen so you can know how much time has passed since the START command was issued.  The value in D(0) is divided by 60 so that it converts the time into Decimal Minutes before displaying the value to the screen with the SHOW command.  Decimal Minutes can be a little confusing at first until you understand how the value past the decimal point can be incremented up to .99 and not stop at 60 as some might expect:

    0.1s (100ms)   / 60 = 0.00 minutes (displayed to the screen)
    0.2s (200ms)   / 60 = 0.00 minutes
    0.3s (300ms)   / 60 = 0.01 minutes

    0.9s (900ms)   / 60 = 0.02 minutes

    1.5s (1500ms)  / 60 = 0.03 minutes

    2.1s (2100ms)  / 60 = 0.04 minutes

    58.8s (58800ms) / 60 = 0.98 minutes

    59.4s (59400ms) / 60 = 0.99 minutes

    60.0s (60000ms) / 60 = 1.00 minutes

    So that is a lot of information.  I hope that it helps and that you can now understand what your program is doing.

    Best Regards,
    Gary

    #12561
    Med_Support
    Moderator
    sharmalab007

    Hi Gary,
    Thankyou very much for the detailed reply. Its really helpful!
    I will follow up with some more questions shortly.
    Suraj

    Hi Gary,

    Again thanks much for your answers. So, i finally got the head entries registered now. It was indeed the input value. I had changed it to 3 but however didnt set up the hardware file correctly. Attached is data from a partial run where i poked 8 times. I have some more questions:

    a) I understood your explanation of LIST B however I do not understand why there are 15 ones instead of 12 ones since there are 12 trials per session.

    b) Does this program have 1 s bins or 2 s bins? the note says 2 but its not obvious to me where in the program the code is.

    c) What is DIM P and what is Phase?

    d) Under SS1 what is set P(^max)=12?

    e) Can you translate SS2 (S1 to S3)?

    f) Can you explain SS7? Where does one get -987.987 from? How do you read S2 ?

    g) Though I got HE separated for pre, post and cue the rates were zero. I am not sure why this is so.

    Thanks

    Suraj

    2014-10-24_14h53m-Subject 1.txt

    #12563
    Med_Support
    Moderator
    Gary Bamberger

    Hi Suraj,

    A)
    The number of values in LIST B is essentially arbitrary.  The value is drawn from LIST B randomly:

    RANDD P(^Cue) = B;

    The RANDD command draws a number from LIST B without replacement.  That means that once a number has been drawn from LIST B it cannot be drawn again until every number has been used at least once and then the list is replenished.  The longer the list the more variability there can be between sessions.  For example:

    LIST B = 0, 1

    If on the first trial a 1 is drawn, then the second trial must be a 0.  But if you expand the length of the list to be:

    LIST B = 0, 1, 1, 0

    Then if on the first trial a 1 is drawn, then on the second you could get a 1 or a 0.

    Right now all of the numbers in LIST B are set to 1 so every trial is rewarded, but you can freely change the length and the values to match whatever percentage of rewarded vs. non-rewarded trials meets your needs.

     

    B)
    This program is currently written to use 1s bins:

    H(0)  = Total Responses Recorded
    H(1)  = Responses that took longer than 30s
    H(2)  = Number of Head Entries that happened between 0.0 - 1.0s after the Trial started
    H(3)  = Number of Head Entries that happened between 1.1 - 2.0s after the Trial started
    H(4)  = Number of Head Entries that happened between 2.1 - 3.0s after the Trial started
    ...
    H(29) = Number of Head Entries that happened between 27.1 - 28.0s after the Trial started
    H(30) = Number of Head Entries that happened between 28.1 - 29.0s after the Trial started
    H(31) = Number of Head Entries that happened between 29.1 - 30.0s after the Trial started
    

    The binning of Head Entries is done with the following code:

    S.S.3,  \\ HE Tracking
    S1,
    #START: ---> S2
    S2,
    #R^Headentry: BIN H, I, .1, 1, 0, 31 ---> S3
    S3,
    0.33": ---> S2
    
    S.S.4,  \\ Index for HE Bins
    S1,
    #START: SET I = 500 ---> S2  \\ Outside Bins Until Beginning of First Trial
    S2,
    0.1": ADD I ---> S2
    #Z1: SET I = 0 ---> S2
    
    

    I don’t really have the space to fully explain everything here, but in S.S.3, S2 the BIN command is what records the Head Entries.  The command is defined as follows:

    Syntax:
    BIN P1,P2,P3,P4,P5,P6

    Where:
    P1 = Array which will hold the frequency distribution.
    P2 = A variable or array element containing the number to be added to the frequency distribution.
    P3 = The units of P2.  If one is recording time, then P3 is how frequently P2 is incremented.
    P4 = The width of each bin or cell of the distribution.
    P5 = Array element, variable, constant, or number denoting the first counter or array element containing the BIN
    distribution.  It is also the element into which the total frequency will be recorded.
    P6 = Array element, variable, constant, or number denoting the last counter or array element into which the BIN
    distribution is recorded.

    It is parameters P3 and P4 that sets the resolution (in this case 0.1s) and width (1s) respectively.

    You can read more about the BIN command in the online help file by starting Trans IV and going to Help | Contents.  When the Help Window opens you can then go to the Index Tab and then find the BIN command in the list that appears.

     

    C)
    The P Array is defined as follows:

    DIM P = 5
    ^ITI         = 0
    ^CUE         = 1  \\whether reinforced or not
    ^MAX         = 2  \\max number of trials
    ^Phase       = 3
    ^event_index = 4
    ^event_time  = 5

    It is basically used to help control the flow of the program.

    The Phase is what part of the Trial is currently active:

    P(^Phase) = 0 = preCue
    = 1 = Cue
    = 2 = postCue

     

    D)
    P(^Max) is the maximum number to trials to run.  After a Trial is run the program checks in S.S.2, S6 if the maximum number of trials has been reached and if yes, the program ends.

    
    E)
    S.S.2,  \\ run
    S1,
    #START: SET D(^Trial) = 0 ---> S2  \ Wait for Start command and initialize the trial counter to 0.
    
    S2,
    0.01": RANDD P(^ITI) = A;             \ Randomly draw an ITI value from LIST A
    SHOW  2,ITI,P(^ITI);           \ Display the ITI value drawn to the screen
    RANDD P(^Cue) = B;             \ Randomly draw rewarded/non-rewarded Trial from LIST B
    SET   P(^ITI) = P(^ITI) * 1";  \ Convert the ITI time from LIST A to MED Ticks
    ADD   D(^Trial) ---> S3        \ Increment the Trial Counter
    
    S3,     \\ ITI, Z1 marks start of trial
    P(^ITI)#T: K1;                 \ K-pulses communicate between Boxes.
    \   This would tell a program running in a different Box that a Trial is starting.
    \   I'm guessing that somewhere at some point in time a Yoked program also
    \   existed that worked in conjunction with this program.
    SET P(^Phase) = 0;  \ Phase = 0 = preCue
    Z1 ---> S4          \ Z-pulses communicate between State Sets
    \   This would tell State Sets 4, 5, 6, & 7 that a Trial is starting
    
    

    F)

    S2,
    #Z14: SET Z(P(^event_index)) = P(^event_time) + .1; ADD P(^event_index); SET Z(P(^event_index)) = -987.987 ---> SX
    #Z1:  SET Z(P(^event_index)) = P(^event_time) + .2; ADD P(^event_index); SET Z(P(^event_index)) = -987.987 ---> SX
    #Z2:  SET Z(P(^event_index)) = P(^event_time) + .3; ADD P(^event_index); SET Z(P(^event_index)) = -987.987 ---> SX
    #Z3:  SET Z(P(^event_index)) = P(^event_time) + .4; ADD P(^event_index); SET Z(P(^event_index)) = -987.987 ---> SX
    #Z4:  SET Z(P(^event_index)) = P(^event_time) + .5; ADD P(^event_index); SET Z(P(^event_index)) = -987.987 ---> SX
    #Z5:  SET Z(P(^event_index)) = P(^event_time) + .6; ADD P(^event_index); SET Z(P(^event_index)) = -987.987 ---> SX
    

    This is the code that keeps track of the Event Index’s that are being recorded in Array Z.

    For example when a Z1 pulse arrives then the program knows that a Trial or preCue is starting and to record that event with the time and .2.

    The value -987.987 seals the Z array so that you do not get all 5000 data elements saved to the data file.  You only get the data that you care about.  Everything up to that value is saved and once that value is hit nothing after is saved to the data file.

     

    G)
    So here is the numbers from the new D Array:

    D:                                                               Rate of HE
    Number of   Responses
    Time Spent    Head Entries  During the
    Session Time   Trials Run    in ITI       During ITI      ITI
    0:      605.900        5.000      485.900        0.000        0.000

    Rate of HE                Rate of HE
    Number of    Responses   Number of     Responses   Number of
    Head Entries   During the  Head Entries  During the  Head Entries
    During PreCue   PreCue     During Cue      Cue       During PostCue
    5:        0.000        0.000        2.000        0.000        6.000

    Rate of HE
    Responses
    During the
    PostCue
    10:        0.000

    There were 2 Head Entries detected during the Cue and 6 during the postCue.  The Head Entry Rate is calculated in S.S.2, S7

    S7,     \\ rate in responses/min, 12 trials X 10s = 120s, 2 min
    30″: OFF ^Fan;
    SET D(^ITIHE_rate)     = H(2)           / (D(^ITI_time) / 60);
    SET D(^cueHE_rate)     = D(^cue_HE)     / 2;
    SET D(^postcueHE_rate) = D(^postcue_HE) / 2;
    SET D(^precue_rate)    = D(^precue_HE)  / 2 —> STOPABORTFLUSH

    But this State only runs after all 12 trials (SET P(^Max) = 12 from S.S.1, S1) have been completed.  From the data file it looks like you stopped the program manually after 5 trials so S.S.2, S7 did not run.

    I think there is a mistake in the equations above.  I believe that you need to use H(1) instead of H(2) because H(1) contains any responses that happened during the ITI.

     

    So that is another long set of answers, but I’m sure your knowledge of how this all works is growing.

    Gary

     

    #12567
    Med_Support
    Moderator
    Gary Bamberger

    This program does not distinguish between the length of Head Entries. It is the time the Head Entry is started that is recorded.

    When a Head Entry is started/detected an input is sent to the program.
    As long as the Head Entry beam remains broken no more inputs are sent to the program.
    When the Head Entry is released and broken again a new input is sent to the program.

    Gary

    #12565
    Med_Support
    Moderator
    sharmalab007

    Thankyou very much again Gary. Yes this is really helping my understanding of the program. You were right about the  code for determining ITI rate, since I was getting zeros though there were HE for ITI.

    Suraj

    Hi Gary,
    Just a quick question. How does the program distinguish HE variability made by the mouse. For instance a mouse could spend 1 s or more than a minute in the nose poke hole. How does the HE counter treat such a situation? Where in the H array does the data go. For example, does a 5 s long HE go into one or multiple H elements?

     

    Thanks

    Suraj

    #12569
    Med_Support
    Moderator
    sharmalab007

    Hi Gary,
    I have two operant boxes . I use the same program for both. The total time is the same for both, however the ITI varies. How can I make them have the same ITI simultaneously?

    Thanks

    Suraj

    #12571
    Med_Support
    Moderator
    Gary Bamberger

    Hi Suraj,

    The easiest way is to replace the RANDD command with the LIST command:

    RANDD P(^ITI) = A;

    becomes:

    LIST P(^ITI) = A(J);

    This will draw the ITI from List A in order so it will be the same in both boxes.

     

    Then what you might want to do is change the order of the values of the LIST from day to day:

    Day 1
    LIST A = 60, 90, 120, 150, 180 \intervals

    Day 2
    LIST A = 120, 180, 60, 150, 90 \intervals

    Day 3
    LIST A = 150, 90, 60, 180, 120 \intervals

     

    You can either have several different versions of the program with the day they are to be run listed in the name or you can load the program and go to “Configure | Change Variables” select LIST A and change the values for that day.

     

    Gary

    #12574
    Med_Support
    Moderator
    sharmalab007

    Hi Gary :

     

    I’m planning to add an external light source which is manufactured from a different vendor. If possible, Can you please give me the code to shine light of 5mV during the program execution.

    #12576
    Med_Support
    Moderator

    To MED-PC the light is just an output. MED-PC doesn’t care what is connected to that output. It could be a retractable lever, pellet dispenser, pump, sonalert, stimulus light, or a light from a different vendor. To turn on a output all you need to do is write ON and the output number. Example:

    ON 5
    
    To turn off the output you just write OFF and the output number:
    
    OFF 5
    
    If for example you want the output on for 1s after a response on input 1 you then time how long the output is turned on:
    
    S.S.4,
    S1,
    #R1: ON 5 ---> S2
    
    S2,
    1": OFF 5 ---> S1
    

    I hope that this info helps.
    Gary

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.