save instruments, scripts and probes as a json file
    Args:
        filename:
        instruments:
        scripts:
        probes: dictionary of the form {instrument_name : probe_1_of_intrument, probe_2_of_intrument, ...}

    Returns:

def save_b26_file(filename, instruments=None, scripts=None, probes=None, overwrite=False, verbose=False):
    """
    save instruments, scripts and probes as a json file
    Args:
        filename:
        instruments:
        scripts:
        probes: dictionary of the form {instrument_name : probe_1_of_intrument, probe_2_of_intrument, ...}

    Returns:

    """

    # if overwrite is false load existing data and append to new instruments
    if os.path.isfile(filename) and overwrite == False:
        data_dict = load_b26_file(filename)
    else:
        data_dict = {}

    if instruments is not None:
        if 'instruments' in data_dict:
            data_dict['instruments'].update(instruments)
        else:
            data_dict['instruments'] = instruments

    if scripts is not None:
        if 'scripts' in data_dict:
            data_dict['scripts'].update(scripts)
        else:
            data_dict['scripts'] = scripts

    if probes is not None:
        probe_instruments = list(probes.keys())
        if 'probes' in data_dict:
            # all the instruments required for old and new probes
            probe_instruments= set(probe_instruments + list(data_dict['probes'].keys()))
        else:
            data_dict.update({'probes':{}})

        for instrument in probe_instruments:
            if instrument in data_dict['probes'] and instrument in probes:
                # update the data_dict
                data_dict['probes'][instrument] = ','.join(set(data_dict['probes'][instrument].split(',') + probes[instrument].split(',')))
            else:
                data_dict['probes'].update(probes)

    if verbose:
        print(('writing ', filename))

    if data_dict != {}:

        # if platform == 'Windows':
        #     # windows can't deal with long filenames so we have to use the prefix '\\\\?\\'
        #     if len(filename.split('\\\\?\\')) == 1:
        #         filename = '\\\\?\\'+ filename
        # create folder if it doesn't exist
        if verbose:
            print(('filename', filename))
            print(('exists', os.path.exists(os.path.dirname(filename))))

        if os.path.exists(os.path.dirname(filename)) is False:
            # print(('creating', os.path.dirname(filename)))
            os.makedirs(os.path.dirname(filename))

        with open(filename, 'w') as outfile:
            tmp = json.dump(data_dict, outfile, indent=4)