Skip to content

flywheel.client

Client

Bases: object

acquisitions property

Returns the acquisitions finder object

collections property

Returns the collections finder object

data_view_executions property

Returns the data_view_executions finder object

gears property

Returns the gears finder object

groups property

Returns the groups finder object

jobs property

Returns the jobs finder object

projects property

Returns the projects finder object

sessions property

Returns the sessions finder object

subjects property

Returns the subjects finder object

users property

Returns the users finder object

View(**kwargs)

Short-hand for flywheel.ViewBuilder(**kwargs).build()

Parameters:

Name Type Description Default
kwargs

The arguments to pass directly to ViewBuilder

{}

Returns:

Type Description

The built data view

__init__(api_key=None, **kwargs)

Initialize Flywheel Client

Note: If you are initializing the client with a drone or device key, you will need to set disable_auth_check to True

Args: api_key: API key to Flywheel kwargs: Other keyword arguments disable_auth_check (bool): Disable authentication check. Default False.

Returns: Initialized Flywheel Client

Raises: flywheel.rest.ApiException: If disable_auth_check is False and authentication fails.

add_collection(*args, **kwargs)

Create a collection

add_gear(gear_name, body, **kwargs)

Create or update a gear.

If no existing gear is found, one will be created Otherwise, the specified gear will be updated

Parameters:

Name Type Description Default
gear_name str

Name of the gear to interact with (required)

required
body GearDocumentLegacyInput

(required)

required
async_ bool

Perform the request asynchronously

required

Returns:

Type Description

GearDocument

add_group(*args, **kwargs)

Add a group

add_job(body, **kwargs)

Add a job

Parameters:

Name Type Description Default
body Job

(required)

required

Returns:

Type Description

CommonObjectCreated

add_user(*args, **kwargs)

Add a new user

download_tar(containers, dest_file, include_types=None, exclude_types=None)

Download the given set of containers as a tarball to dest_file.

Supports downloading Projects, Sessions, Acquisitions and/or Analyses.

Parameters:

Name Type Description Default
containers

(required) The container, or list of containers to download.

required
dest_file str

(required) The destination file on disk

required
include_types list

The optional list of types to include in the download (e.g. ['nifti'])

None
exclude_types list

The optional list of types to exclude from the download (e.g. ['dicom'])

None

Returns:

Type Description

A summary of the download

download_zip(containers, dest_file, include_types=None, exclude_types=None)

Download the given set of containers as a zip archive to dest_file.

Supports downloading Projects, Sessions, Acquisitions and/or Analyses.

Parameters:

Name Type Description Default
containers

(required) The container, or list of containers to download.

required
dest_file str

(required) The destination file on disk

required
include_types list

The optional list of types to include in the download (e.g. ['nifti'])

None
exclude_types list

The optional list of types to exclude from the download (e.g. ['dicom'])

None

Returns:

Type Description

A summary of the download

file_url(path)

Perform a path based lookup of a file in the Flywheel hierarchy, and return a single-use download URL.

Parameters:

Name Type Description Default
path str

(required) The path to resolve

required

Returns:

Type Description

The file URL if found, otherwise raises an error

get(id, **kwargs)

Retrieve the specified object by id.

Objects that can be retrieved in this way are: group, project, session, subject, acquisition, analysis and collection

Parameters:

Name Type Description Default
id str

The id of the object to retrieve

required

Returns:

Type Description

ContainerOutput

get_config(**kwargs)

Return public Scitran configuration information

Returns:

Type Description

ConfigOut

get_current_user(**kwargs)

Get current logged-in user

Returns:

Type Description

User

get_gear(gear_id, **kwargs)

Return a gear referenced by gear_id

Parameters:

Name Type Description Default
gear_id str

(required) The id of the gear to lookup

required

Returns:

Type Description

Gear

get_modality(modality_id, **kwargs)

Get a modality's classification specification

Parameters:

Name Type Description Default
modality_id str

(required)

required

Returns:

Type Description

Modality

get_version(**kwargs)

Get server and database schema version info

Returns:

Type Description

VersionOutput

lookup(path)

Perform a path based lookup of a single node in the Flywheel hierarchy.

Parameters:

Name Type Description Default
path str

(required) The path to resolve

required

Returns:

Type Description

ResolverOutput

print_view_columns(file=sys.stdout)

Print a list of column aliases that can be used in data views.

Parameters:

Name Type Description Default
file file - like

The file to print to

stdout

read_view_data(view, container_id, decode=True, **kwargs)

Execute a data view against container, and return a file-like object that can be streamed.

Parameters:

Name Type Description Default
view str | DataView

The view id or DataView object to execute.

required
container_id str

The id of the container to execute the view against

required
decode bool

Whether or not to decode the stream to utf-8 (default is true)

True
kwargs

Additional arguments to pass to the evaluate_view call. (e.g. format='csv')

{}

Returns:

Type Description

A file-like object where the contents can be read

read_view_dataframe(view, container_id, opts=None, **kwargs)

Execute a data view against container, and return a DataFrame.

NOTE: This requires that the pandas module be installed on the system.

Parameters:

Name Type Description Default
view str | DataView

The view id or DataView object to execute.

required
container_id str

The id of the container to execute the view against

required
opts object

Additional options to pass to the pandas read_json function

None
kwargs

Additional arguments to pass to the evaluate_view call.

{}

Returns:

Type Description

A pandas DataFrame

resolve(path)

Perform a path based lookup of nodes in the Flywheel hierarchy.

Parameters:

Name Type Description Default
path str

(required) The path to resolve

required

Returns:

Type Description

ResolverOutput

save_view_data(view, container_id, dest_file, **kwargs)

Execute a data view against container, and save the results to disk.

Parameters:

Name Type Description Default
view str | DataView

The view id or DataView object to execute.

required
container_id str

The id of the container to execute the view against

required
dest_file str

The destination file path

required
kwargs

Additional arguments to pass to the evaluate_view call. (e.g. format='csv')

{}

shutdown()

Release any outstanding resources