Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add watermark #829

Closed
wants to merge 12 commits into from
20 changes: 17 additions & 3 deletions src/pyflask/manageNeuroconv/manage_neuroconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@

from tqdm_publisher import TQDMProgressHandler

from .info import CONVERSION_SAVE_FOLDER_PATH, GUIDE_ROOT_FOLDER, STUB_SAVE_FOLDER_PATH
from .info import (
CONVERSION_SAVE_FOLDER_PATH,
GUIDE_ROOT_FOLDER,
STUB_SAVE_FOLDER_PATH,
is_packaged,
resource_path,
)
from .info.sse import format_sse

progress_handler = TQDMProgressHandler()
Expand Down Expand Up @@ -869,8 +875,8 @@ def convert_to_nwb(
) -> str:
"""Function used to convert the source data to NWB format using the specified metadata."""

import neuroconv
import requests
from neuroconv import NWBConverter
from tqdm_publisher import TQDMProgressSubscriber

url = info.get("url", None)
Expand Down Expand Up @@ -983,7 +989,7 @@ def update_conversion_progress(message):

interface_or_subconverter = converter.data_interface_objects[sub_interface]

if isinstance(interface_or_subconverter, NWBConverter):
if isinstance(interface_or_subconverter, neuroconv.NWBConverter):
subconverter = interface_or_subconverter

update_recording_properties_from_table_as_json(
Expand Down Expand Up @@ -1016,6 +1022,14 @@ def update_conversion_progress(message):
resolved_metadata["Subject"]["date_of_birth"]
).replace(tzinfo=zoneinfo.ZoneInfo(info["timezone"]))

# Add GUIDE watermark
package_json_file_path = resource_path("../package.json" if is_packaged() else "../package.json")
with open(file=package_json_file_path) as fp:
package_json = json.load(fp=fp)
app_version = package_json["version"]
resolved_metadata["NWBFile"]["source_script"] = f"Created using NWB GUIDE v{app_version}"
resolved_metadata["NWBFile"]["source_script_file_name"] = neuroconv.__file__ # Must be included to be valid

# Actually run the conversion
converter.run_conversion(
metadata=resolved_metadata,
Expand Down
Loading