def calculateMinMax(driver, sample_rate, iscr_win, minmax_win, pipeout):
    """
    Compute minimum and maximum ISCR values for normalisation.
    Intented to be used as a separate process to allow caller to process raw data.

    parameters:
    driver : scr phasic driver
    sample_rate : post-analysis sampling rate
    iscr_win : window (s) for iscr calculation
    minmax_win : window size (s) for minmax calculation (set to 0 to cover whole driver)
    pipeout : sends min and max through this pipe
    pipes out a tuple (iscr_min, iscr_max)
    """
    iscr_min = float('inf')
    iscr_max = float('-inf')
    if minmax_win == 0:
        startpoint = -len(driver)
    else:
        startpoint = int(-minmax_win * sample_rate)
    endpoint = startpoint + iscr_win * sample_rate
    while endpoint <= 0:
        iscr = driver[startpoint:endpoint].sum()
        if iscr > iscr_max:
            iscr_max = iscr
        if iscr < iscr_min:
            iscr_min = iscr
        startpoint += 1
        endpoint += 1
    pipeout.send((iscr_min, iscr_max))
    pipeout.close()
