Project¶
The project
module helps downloading the data from the PhotosynQ, Inc.
platform, as well as managing files locally and display information about a locally saved project.
The Data related functions are loading the data either from a cloud or local source.
View Info functions display the information about the project and the File Functions
are helper functions to manage the local files. While they can be used individually they
should not be required to use if functions like get()
and
print_info()
are used.
Data¶
Extension of the PhotosynQ Python Library to download project data and information as well as save a local copy for subsequent faster data loading and offline work.
- get(email=None, projectId=None, directory='.', processed_data=True, raw_traces=False, force=False)[source]¶
Get the data for a Project based on it’s ID. In case data and info files exist locally already, they will be used for loading the data. Otherwise, the data will be downloaded from the PhotosynQ platform and files will be saved locally for future use.
- Parameters:
email (str) – The email used for the PhotosynQ account. If not provided, a local copy will be loaded, if available.
project_id (int or str) – The project’s ID as found on PhotosynQ. If not provided, a ValueError will be raised.
directory (str) – The file location. Defaults to the current directory (“.”).
processed_data (bool) – Including processed data into the requested project data. Defaults to True.
raw_traces (bool) – Including raw data traces in the requested project data. Defaults to False, as data files could be large.
force (bool) – If True a download is forced, overwriting existing files. Defaults to False.
- Returns:
A list of DataFrames representing the project’s data and the project’s information. Each will be set to None if the corresponding file is not found.
- Return type:
list[pandas.DataFrame], dict
- Raises:
ValueError – If no project ID is provided.
ValueError – If provided project ID is not an integer.
- Alias:
download()
Note
If you don’t have the local data available, you need an account for PhotosynQ, Inc. to download the data.
View Info¶
Function to help view project information.
- print_info(project=None, show_code=False)[source]¶
Print formatted information about the provided Project.
- Parameters:
project (dict) – Project information as returned by
get()
orload()
.show_code (bool) – Display the protocol’s code in addition to the description. Defaults to False.
- Returns:
None
- Return type:
NoneType
- Raises:
ValueError – if no project data is provided or the project data has the wrong format
- Alias:
show()
File Functions¶
Functions to help working with local project data and information files.
- file_df_name(projectId)[source]¶
Generate the default file name for project data file.
- Parameters:
projectId (int or str) – The project’s ID as found on PhotosynQ. If not provided, an Exception will be raised.
- Returns:
The default file name for the project data frame.
- Return type:
str
- Raises:
ValueError – If no project ID is provided.
- file_info_name(projectId)[source]¶
Generate the default file name for project info file.
- Parameters:
projectId (int or str) – The project’s ID as found on PhotosynQ. If not provided, an Exception will be raised.
- Returns:
The default file name for the project information.
- Return type:
str
- Raises:
ValueError – If no project ID is provided.
- file_exists(filename='', directory='.')[source]¶
Check if local file exists.
- Parameters:
filename (str) – The filename of the file. Defaults to an empty string.
directory (str) – The file location. Defaults to the current directory (“.”).
- Returns:
True if the file exists, False otherwise.
- Return type:
bool
- Raises:
ValueError – If filename or directory are not strings.
- save(projectId, directory='.', df=None, info=None)[source]¶
Save project data and information to local files. For the data a file named like
PhotosynQ_xxx.pickle
will be saved. The content is compressed using thezip
algorithm. For the project information a file in theJSON
format is saved.- Parameters:
projectId (int or str) – The project’s ID as found on PhotosynQ. If not provided, an Exception will be raised.
directory (str) – The file location. Defaults to the current directory (“.”).
df (list[dataframe]) – List of dataframes as returned by
get()
info (dict) – Project information as returned by
get()
- Returns:
None
- Return type:
NoneType
- Raises:
ValueError – If no project ID is provided.
ValueError – If directory is not a string.
- load(projectId, directory='.')[source]¶
Load a project’s data and information based on the project’s ID from the local drive.
- Parameters:
project_id (int or str) – The project’s ID as found on PhotosynQ. If not provided, a ValueError will be raised.
directory (str) – The file location. Defaults to the current directory (“.”).
- Returns:
A list of DataFrames representing the project’s data and the project’s information. Each will be set to None if the corresponding file is not found.
- Return type:
list[pandas.DataFrame], dict