Ejemplo n.º 1
0
def create_ephyspc_params(force=False):
    if Path(params.getfile('ephyspc_params')).exists() and not force:
        print(f"{params.getfile('ephyspc_params')} exists already, exiting...")
        print(Path(params.getfile('ephyspc_params')).exists())
        return
    data_folder_path = cli_ask_default(
        r"Where's your LOCAL 'Subjects' data folder?",
        r"D:\iblrig_data\Subjects")
    remote_data_folder_path = cli_ask_default(
        r"Where's your REMOTE 'Subjects' data folder?",
        r"\\iblserver.champalimaud.pt\ibldata\Subjects")
    probe_type_00 = cli_ask_options("What's the type of PROBE 00?",
                                    ['3A', '3B'])
    probe_type_01 = cli_ask_options("What's the type of PROBE 01?",
                                    ['3A', '3B'])
    param_dict = {
        'DATA_FOLDER_PATH': data_folder_path,
        'REMOTE_DATA_FOLDER_PATH': remote_data_folder_path,
        'PROBE_TYPE_00': probe_type_00,
        'PROBE_TYPE_01': probe_type_01,
    }
    params.write('ephyspc_params', param_dict)
    print(f"Created {params.getfile('ephyspc_params')}")
    print(param_dict)
    return param_dict
Ejemplo n.º 2
0
def create_ephyspc_params(force=False, silent=False):
    if Path(params.getfile("ephyspc_params")).exists() and not force:
        print(f"{params.getfile('ephyspc_params')} exists already, exiting...")
        print(Path(params.getfile("ephyspc_params")).exists())
        return
    if silent:
        data_folder_path = r"D:\iblrig_data\Subjects"
        remote_data_folder_path = r"\\iblserver.champalimaud.pt\ibldata\Subjects"
        probe_type_00 = "3A"
        probe_type_01 = "3B"
    else:
        data_folder_path = cli_ask_default(
            r"Where's your LOCAL 'Subjects' data folder?",
            r"D:\iblrig_data\Subjects")
        remote_data_folder_path = cli_ask_default(
            r"Where's your REMOTE 'Subjects' data folder?",
            r"\\iblserver.champalimaud.pt\ibldata\Subjects",
        )
        probe_type_00 = cli_ask_options("What's the type of PROBE 00?",
                                        ["3A", "3B"])
        probe_type_01 = cli_ask_options("What's the type of PROBE 01?",
                                        ["3A", "3B"])
    param_dict = {
        "DATA_FOLDER_PATH": data_folder_path,
        "REMOTE_DATA_FOLDER_PATH": remote_data_folder_path,
        "PROBE_TYPE_00": probe_type_00,
        "PROBE_TYPE_01": probe_type_01,
    }
    params.write("ephyspc_params", param_dict)
    print(f"Created {params.getfile('ephyspc_params')}")
    print(param_dict)
    return param_dict
Ejemplo n.º 3
0
def create_videopc_params(force=False):
    if Path(params.getfile('videopc_params')).exists() and not force:
        print(f"{params.getfile('videopc_params')} exists already, exiting...")
        print(Path(params.getfile('videopc_params')).exists())
        return
    data_folder_path = cli_ask_default(
        r"Where's your LOCAL 'Subjects' data folder?",
        r"D:\iblrig_data\Subjects")
    remote_data_folder_path = cli_ask_default(
        r"Where's your REMOTE 'Subjects' data folder?",
        r"\\iblserver.champalimaud.pt\ibldata\Subjects")
    body_cam_idx = cli_ask_default(
        "Please select the index of the BODY camera", '0')
    left_cam_idx = cli_ask_default(
        "Please select the index of the LEFT camera", '1')
    right_cam_idx = cli_ask_default(
        "Please select the index of the RIGHT camera", '2')

    param_dict = {
        'DATA_FOLDER_PATH': data_folder_path,
        'REMOTE_DATA_FOLDER_PATH': remote_data_folder_path,
        'BODY_CAM_IDX': body_cam_idx,
        'LEFT_CAM_IDX': left_cam_idx,
        'RIGHT_CAM_IDX': right_cam_idx,
    }
    params.write('videopc_params', param_dict)
    print(f"Created {params.getfile('videopc_params')}")
    print(param_dict)
    return param_dict
Ejemplo n.º 4
0
def create_videopc_params():
    if VIDEOPC_PARAMS_FILE.exists():
        print(f"{VIDEOPC_PARAMS_FILE} exists already, exiting...")
        return
    else:
        default = " [default: {}]: "
        data_folder_path = input(r"Where's your 'Subjects' data folder?" +
                                 default.format(r"C:\iblrig_data\Subjects")
                                 ) or r"C:\iblrig_data\Subjects"
        body_cam_idx = input("Please select the index of the BODY camera" +
                             default.format(0)) or 0
        left_cam_idx = input("Please select the index of the LEFT camera" +
                             default.format(1)) or 1
        right_cam_idx = input("Please select the index of the RIGHT camera" +
                              default.format(2)) or 2

        param_dict = {
            'DATA_FOLDER_PATH': data_folder_path,
            'BODY_CAM_IDX': body_cam_idx,
            'LEFT_CAM_IDX': left_cam_idx,
            'RIGHT_CAM_IDX': right_cam_idx,
        }
        params.write('videopc_params', param_dict)
        print(f"Created {VIDEOPC_PARAMS_FILE}")
        return
Ejemplo n.º 5
0
def setup():
    par_default = default()
    par_current = iopar.read(_PAR_ID_STR, par_default)

    par = iopar.as_dict(par_default)
    for k in par.keys():
        cpar = _get_current_par(k, par_current)
        if "PWD" not in k:
            par[k] = input("Param " + k + ",  current value is [" + str(cpar) +
                           "]:") or cpar

    cpar = _get_current_par("ALYX_PWD", par_current)
    prompt = "Enter the Alyx password for " + par[
        "ALYX_LOGIN"] + '(leave empty to keep current):'
    par["ALYX_PWD"] = getpass(prompt) or cpar

    cpar = _get_current_par("HTTP_DATA_SERVER_PWD", par_current)
    prompt = "Enter the FlatIron HTTP password for " + par["HTTP_DATA_SERVER_LOGIN"] +\
             '(leave empty to keep current): '
    par["HTTP_DATA_SERVER_PWD"] = getpass(prompt) or cpar

    # default to home dir if empty dir somehow made it here
    if len(par['CACHE_DIR']) == 0:
        par['CACHE_DIR'] = str(Path.home() / "Downloads" / "FlatIron")

    par = iopar.from_dict(par)

    # create directory if needed
    if par.CACHE_DIR and not os.path.isdir(par.CACHE_DIR):
        os.mkdir(par.CACHE_DIR)
    iopar.write(_PAR_ID_STR, par)
    print('ONE Parameter file location: ' + iopar.getfile(_PAR_ID_STR))
Ejemplo n.º 6
0
def setup_alyx_params():
    setup_silent()
    par = iopar.read(_PAR_ID_STR).as_dict()
    [usr, pwd] = login(title='Alyx credentials')
    par['ALYX_LOGIN'] = usr
    par['ALYX_PWD'] = pwd
    iopar.write(_PAR_ID_STR, par)
Ejemplo n.º 7
0
 def setUp(self):
     self.par_dict = {'A': 'tata',
                      'O': 'toto',
                      'I': 'titi',
                      'num': 15,
                      'liste': [1, 'turlu']}
     params.write('toto', self.par_dict)
     params.write('toto', params.from_dict(self.par_dict))
Ejemplo n.º 8
0
 def test_setup_silent(self):
     self.assertIsNone(iopar.read(params._PAR_ID_STR))
     params.setup_silent()
     par = iopar.read(params._PAR_ID_STR)
     self.assertIsNotNone(par)
     # now do another test to see if it preserves current values
     par = par.as_dict()
     par['ALYX_LOGIN'] = '******'
     iopar.write(params._PAR_ID_STR, par)
     params.setup_silent()
     par2 = iopar.read(params._PAR_ID_STR)
     self.assertEqual(par, par2.as_dict())
Ejemplo n.º 9
0
def AllenAtlas(res_um=25, par=None):
    """
    Instantiates an atlas.BrainAtlas corresponding to the Allen CCF at the given resolution
    using the IBL Bregma and coordinate system
    :param res_um: 25 or 50 um
    :return: atlas.BrainAtlas
    """
    if par is None:
        # Bregma indices for the 10um Allen Brain Atlas, mlapdv
        pdefault = {
            'PATH_ATLAS':
            '/datadisk/BrainAtlas/ATLASES/Allen/',
            'FILE_REGIONS':
            str(Path(__file__).parent.joinpath('allen_structure_tree.csv')),
            'INDICES_BREGMA':
            list(np.array([1140 - (570 + 3.9), 540, 0 + 33.2]))
        }
        par = params.read('ibl_histology', default=pdefault)
        if not Path(par.PATH_ATLAS).exists():
            raise NotImplementedError(
                "Atlas doesn't exist ! Mock option not implemented yet")
            # TODO: mock atlas to get only the coordinate framework
            pass
        params.write('ibl_histology', par)
    else:
        par = Bunch(par)
    # file_image = Path(path_atlas).joinpath(f'ara_nissl_{res_um}.nrrd')
    file_image = Path(
        par.PATH_ATLAS).joinpath(f'average_template_{res_um}.nrrd')
    file_label = Path(par.PATH_ATLAS).joinpath(f'annotation_{res_um}.nrrd')
    image, header = nrrd.read(file_image, index_order='C')  # dv, ml, ap
    image = np.swapaxes(np.swapaxes(image, 2, 0), 1, 2)  # image[iap, iml, idv]
    label, header = nrrd.read(file_label, index_order='C')  # dv, ml, ap
    label = np.swapaxes(np.swapaxes(label, 2, 0), 1, 2)  # label[iap, iml, idv]
    # resulting volumes origin: x right, y front, z top
    df_regions = pd.read_csv(par.FILE_REGIONS)
    regions = BrainRegions(id=df_regions.id.values,
                           name=df_regions.name.values,
                           acronym=df_regions.acronym.values)
    xyz2dims = np.array([1, 0, 2])
    dims2xyz = np.array([1, 0, 2])
    dxyz = res_um * 1e-6 * np.array([-1, -1, -1])
    ibregma = (np.array(par.INDICES_BREGMA) * 10 / res_um)
    return BrainAtlas(image,
                      label,
                      regions,
                      dxyz,
                      ibregma,
                      dims2xyz=dims2xyz,
                      xyz2dims=xyz2dims)
Ejemplo n.º 10
0
def setup_silent():
    par_current = iopar.read(_PAR_ID_STR)
    par_default = default()
    if par_current is None:
        par = par_default
    else:
        par = iopar.as_dict(par_default)
        for k in par.keys():
            cpar = _get_current_par(k, par_current)
            par[k] = cpar
        par = iopar.from_dict(par)

    if par.CACHE_DIR:
        Path(par.CACHE_DIR).mkdir(parents=True, exist_ok=True)
    iopar.write(_PAR_ID_STR, par)
Ejemplo n.º 11
0
def create_ephyspc_params():
    if EPHYSPC_PARAMS_FILE.exists():
        print(f"{EPHYSPC_PARAMS_FILE} exists already, exiting...")
        return
    else:
        default = " [default: {}]: "
        data_folder_path = input(r"Where's your 'Subjects' data folder?" +
                                 default.format(r"C:\iblrig_data\Subjects")
                                 ) or r"C:\iblrig_data\Subjects"

        param_dict = {
            'DATA_FOLDER_PATH': data_folder_path,
        }
        params.write('ephyspc_params', param_dict)
        print(f"Created {EPHYSPC_PARAMS_FILE}")
        return
Ejemplo n.º 12
0
def create_videopc_params(force=False, silent=False):
    if Path(params.getfile("videopc_params")).exists() and not force:
        print(f"{params.getfile('videopc_params')} exists already, exiting...")
        print(Path(params.getfile("videopc_params")).exists())
        return
    if silent:
        data_folder_path = r"D:\iblrig_data\Subjects"
        remote_data_folder_path = r"\\iblserver.champalimaud.pt\ibldata\Subjects"
        body_cam_idx = 0
        left_cam_idx = 1
        right_cam_idx = 2
    else:
        data_folder_path = cli_ask_default(
            r"Where's your LOCAL 'Subjects' data folder?",
            r"D:\iblrig_data\Subjects")
        remote_data_folder_path = cli_ask_default(
            r"Where's your REMOTE 'Subjects' data folder?",
            r"\\iblserver.champalimaud.pt\ibldata\Subjects",
        )
        body_cam_idx = cli_ask_default(
            "Please select the index of the BODY camera", "0")
        left_cam_idx = cli_ask_default(
            "Please select the index of the LEFT camera", "1")
        right_cam_idx = cli_ask_default(
            "Please select the index of the RIGHT camera", "2")

    param_dict = {
        "DATA_FOLDER_PATH": data_folder_path,
        "REMOTE_DATA_FOLDER_PATH": remote_data_folder_path,
        "BODY_CAM_IDX": body_cam_idx,
        "LEFT_CAM_IDX": left_cam_idx,
        "RIGHT_CAM_IDX": right_cam_idx,
    }
    params.write("videopc_params", param_dict)
    print(f"Created {params.getfile('videopc_params')}")
    print(param_dict)
    return param_dict
Ejemplo n.º 13
0
def setup(globus_client_id, str_app='globus/default'):
    # Lookup and manage consents there
    # https://auth.globus.org/v2/web/consents
    gtok = _login(globus_client_id, refresh_tokens=True)
    params.write(str_app, gtok)
Ejemplo n.º 14
0
print("""Setting up Globus
1. Login to the Globus Website (ask devs for the login credentials)
2. Go to Endpoints and create a new endpoint for the local device (the one that will run this
script).
3. In the new endpoint's overview page, copy the 'Endpoint UUID' field.  This is the LOCAL_REPO_ID.
4. Go to the 'IBL Top Level' endpoint overview page and copy the 'Endpoint UUID' field.  This is
the REMOTE_REPO_ID.
5. Copy your GLOBUS_CLIENT_ID (ask the software devs for this).
""")
params_id = 'globus/admin'
pars = params.read(params_id, DEFAULT_PAR)
default = pars.local_endpoint
local_endpoint = input(f'Enter your LOCAL_REPO_ID ({default}):')
pars = pars.set('local_endpoint', local_endpoint.strip() or default)
params.write(params_id, pars)

default = pars.remote_endpoint
remote_endpoint = input(f'Enter your REMOTE_REPO_ID ({default}):')
pars = pars.set('remote_endpoint', remote_endpoint.strip() or default)
params.write(params_id, pars)

default = pars.GLOBUS_CLIENT_ID
globus_client_id = input(f'Enter your GLOBUS_CLIENT_ID ({default}):').strip()
pars = pars.set('GLOBUS_CLIENT_ID', globus_client_id or default)
params.write(params_id, pars)

print("""Setting up fixtures
You will now need to define a directory to which you will download the integration test data.
""")
params_id = 'ibl_ci'