Closed jordiabante closed 5 months ago
If you're confident it's an ffmpeg issue then it shouldn't be save_minian as that only saves the data structure to a zarr array and as far as I understand it doesn't make any calls to ffmpeg https://github.com/denisecailab/minian/blob/f64c456ca027200e19cf40a80f0596106918fd09/minian/utilities.py#L440.
This is a bit of a long shot but since you didn't have any issues with loading the video into an xarray I would investigate what datatype is currently stored in the Y array and maybe converting that into something more memory efficient before calling write_video. Another solution would be to slice the array into smaller chunks (in halves or quarters?) generating the video files and then combining them.
Edit 1: Forget my suggestion of changing the datatype, it seems that this is already accounted for in the code, as they convert it to uint8.
Edit 2: From what I can see from the code it should be only saving it in chunks: https://github.com/denisecailab/minian/blob/f64c456ca027200e19cf40a80f0596106918fd09/minian/visualization.py#L1275C5-L1276C53
Might be worth investigating how your data is chunked and maybe chunking it into smaller pieces.
Hi Jordiabante,
8GB is quite small, so I'm surprised you're having an issue converting Y to Y_fm_chk and saving the motion correction video. You could try converting to float32 instead of float64, but I suspect this isn't the issue.
Looking at your Dask cluster, you are initializing the cluster with 1 worker that then gets allocated a memory limit of 30GB:
## Your current cluster configuration
n_workers = int(os.getenv("MINIAN_NWORKERS", 1))
cluster = LocalCluster(
n_workers=n_workers,
memory_limit="30GB",
resources={"MEM": 1},
threads_per_worker=4,
dashboard_address=":8585",
)
I have never tried to use Minian with one worker, and I suspect this may be the issue (even with the 4 threads, or 4 cores per worker). I would recommend doing anywhere from 5-7 workers and adjusting their memory limit accordingly, while also decreasing the threads_per_worker to 2 cores:
## Potential cluster configuration
n_workers = int(os.getenv("MINIAN_NWORKERS", 5))
cluster = LocalCluster(
n_workers=n_workers,
memory_limit="7GB",
resources={"MEM": 1},
threads_per_worker=2,
dashboard_address=":8585",
)
The configuration above would work with your computer's 64GB of RAM, as it would only utilize (at most) 35GB.
Let me know if this works!
Hi all,
Thanks for your suggestions.
@GrowlingM1ke, I believe save_minian does call ffmpeg (I see a call in the stderr that corresponds to that part of the code in principle). Regarding the chunks we are using function get_optimal_chk to obtain the optimal size. Shouldn't that take care of it?
@austinbaggetta I modified the cluster set up to:
## Potential cluster configuration
n_workers = int(os.getenv("MINIAN_NWORKERS", 5))
cluster = LocalCluster(
n_workers=n_workers,
memory_limit="7GB",
resources={"MEM": 1},
threads_per_worker=2,
dashboard_address=":8585"
)
annt_plugin = TaskAnnotation()
cluster.scheduler.add_plugin(annt_plugin)
client = Client(cluster)
and I get the following error:
Task exception was never retrieved
future: <Task finished name='Task-13' coro=<_wrap_awaitable() done, defined at /media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/asyncio/tasks.py:688> exception=RuntimeError('\n An attempt has been made to start a new process before the\n current process has finished its bootstrapping phase.\n\n This probably means that you are not using fork to start your\n child processes and you have forgotten to use the proper idiom\n in the main module:\n\n if __name__ == \'__main__\':\n freeze_support()\n ...\n\n The "freeze_support()" line can be omitted if the program\n is not going to be frozen to produce an executable.')>
Traceback (most recent call last):
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/asyncio/tasks.py", line 695, in _wrap_awaitable
return (yield from awaitable.__await__())
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/site-packages/distributed/core.py", line 284, in _
await self.start()
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/site-packages/distributed/nanny.py", line 295, in start
response = await self.instantiate()
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/site-packages/distributed/nanny.py", line 378, in instantiate
result = await self.process.start()
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/site-packages/distributed/nanny.py", line 575, in start
await self.process.start()
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/site-packages/distributed/process.py", line 33, in _call_and_set_future
res = func(*args, **kwargs)
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/site-packages/distributed/process.py", line 203, in _start
process.start()
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/multiprocessing/context.py", line 284, in _Popen
return Popen(process_obj)
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in __init__
super().__init__(process_obj)
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 42, in _launch
prep_data = spawn.get_preparation_data(process_obj._name)
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/multiprocessing/spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/multiprocessing/spawn.py", line 134, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
Do you have any ideas? I am not familiar at all with Dask, so this could very well be something very basic.
Thanks!
Hi all,
I modified the cluster definition to:
if __name__ == '__main__':
## Potential cluster configuration
n_workers = int(os.getenv("MINIAN_NWORKERS", 7))
cluster = LocalCluster(
n_workers=n_workers,
memory_limit="5GB",
resources={"MEM": 1},
threads_per_worker=2,
dashboard_address=":8585",
start_method='fork' # or 'spawn'
)
annt_plugin = TaskAnnotation()
cluster.scheduler.add_plugin(annt_plugin)
try:
client = Client(cluster)
# Your Dask computations using the client
finally:
# Close the client and cluster explicitly
client.close()
cluster.close()
This doesn't produce the same error. However, the code seems to get stuck (using 5 and 7 workers) at the same point it does when I don't use a cluster. At this point the 64Gb are all being used (ignoring the restriction by the cluster) and the swp memory starts increasing until it maxes out and then the process gets killed.
[2024-04-18 12:03:04.356140] Configuration...
[2024-04-18 12:03:04.356336] Importing minian...
[2024-04-18 12:03:39.139878] Initialiazing...
[2024-04-18 12:03:39.139929] Starting cluster...
[2024-04-18 12:03:40.667591] Configuration...
[2024-04-18 12:03:40.667641] Importing minian...
[2024-04-18 12:03:40.676275] Configuration...
[2024-04-18 12:03:40.676334] Importing minian...
[2024-04-18 12:03:40.676715] Configuration...
[2024-04-18 12:03:40.676764] Importing minian...
[2024-04-18 12:03:40.685165] Configuration...
[2024-04-18 12:03:40.685230] Importing minian...
[2024-04-18 12:03:40.691049] Configuration...
[2024-04-18 12:03:40.691113] Importing minian...
[2024-04-18 12:03:40.692652] Configuration...
[2024-04-18 12:03:40.692708] Importing minian...
[2024-04-18 12:03:40.717103] Configuration...
[2024-04-18 12:03:40.717164] Importing minian...
[2024-04-18 12:03:43.871927] Initialiazing...
[2024-04-18 12:03:43.872141] Starting cluster...
[2024-04-18 12:03:43.872180] Loading videos...
[2024-04-18 12:03:43.894702] Initialiazing...
[2024-04-18 12:03:43.894741] Starting cluster...
[2024-04-18 12:03:43.894747] Loading videos...
loading 1 videos in folder /media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected
loading 1 videos in folder /media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected
[2024-04-18 12:03:43.922585] Initialiazing...
[2024-04-18 12:03:43.922622] Starting cluster...
[2024-04-18 12:03:43.922628] Loading videos...
[2024-04-18 12:03:43.922760] Initialiazing...
[2024-04-18 12:03:43.922790] Starting cluster...
[2024-04-18 12:03:43.922796] Loading videos...
loading 1 videos in folder /media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected
loading 1 videos in folder /media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected
[2024-04-18 12:03:43.924899] Initialiazing...
[2024-04-18 12:03:43.924936] Starting cluster...
[2024-04-18 12:03:43.924942] Loading videos...
loading 1 videos in folder /media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected
[2024-04-18 12:03:43.954685] Initialiazing...
[2024-04-18 12:03:43.954718] Starting cluster...
[2024-04-18 12:03:43.954725] Loading videos...
loading 1 videos in folder /media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected
[2024-04-18 12:03:43.959545] Initialiazing...
[2024-04-18 12:03:43.959578] Starting cluster...
[2024-04-18 12:03:43.959584] Loading videos...
loading 1 videos in folder /media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected
[2024-04-18 12:03:44.535566] Glow removal...
[2024-04-18 12:03:44.535610] Glow removal...
[2024-04-18 12:03:44.535615] Glow removal...
[2024-04-18 12:03:44.535614] Glow removal...
[2024-04-18 12:03:44.535648] Glow removal...
[2024-04-18 12:03:44.535660] Glow removal...
[2024-04-18 12:03:44.535673] Glow removal...
ffmpeg version 4.2.3ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
ffmpeg version 4.2.3 libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
Copyright (c) 2000-2020 the FFmpeg developers libavutil 56. 31.100 / 56. 31.100
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libavutil 56. 31.100 / 56. 31.100
libswscale 5. 5.100 / 5. 5.100
libavcodec 58. 54.100 / 58. 54.100
libswresample 3. 5.100 / 3. 5.100
libavformat 58. 29.100 / 58. 29.100
libpostproc 55. 5.100 / 55. 5.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration: Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
00:11:00.20 Duration: , start: 00:11:00.200.000000, start: , bitrate: 0.000000104203 kb/s, bitrate:
104203 kb/s
Stream #0:0 Stream #0:0: Video: rawvideo, pal8, 806x806, 104207 kb/s: Video: rawvideo, pal8, 806x806, 104207 kb/s, , 20 fps, 20 fps, 20 tbr, 20 tbr, 20 tbn, 20 tbn, 20 tbc20 tbc
Stream mapping:
Stream mapping:
Stream #0:0 -> #0:0 Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native)) (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Press [q] to stop, [?] for help
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration: 00:11:00.20, start: 0.000000, bitrate: 104203 kb/s
ffmpeg version 4.2.3 Stream #0:0 Copyright (c) 2000-2020 the FFmpeg developers: Video: rawvideo, pal8, 806x806, 104207 kb/s
, built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
20 fps, 20 tbr, 20 tbn, 20 tbc
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration: 00:11:00.20, start: 0.000000, bitrate: 104203 kb/s
Stream #0:0: Video: rawvideo, pal8, 806x806, 104207 kb/s, 20 fps, 20 tbr, 20 tbn, 20 tbc
Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration: 00:11:00.20, start: 0.000000, bitrate: 104203 kb/s
Stream #0:0: Video: rawvideo, pal8, 806x806, 104207 kb/s, 20 fps, 20 tbr, 20 tbn, 20 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration: 00:11:00.20, start: 0.000000, bitrate: 104203 kb/s
Stream #0:0: Video: rawvideo, pal8, 806x806, 104207 kb/s, 20 fps, 20 tbr, 20 tbn, 20 tbc
Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration: 00:11:00.20, start: 0.000000, bitrate: 104203 kb/s
Stream #0:0: Video: rawvideo, pal8, 806x806, 104207 kb/sStream mapping:
, Stream #0:0 -> #0:020 fps, (rawvideo (native) -> rawvideo (native))20 tbr,
20 tbn, Press [q] to stop, [?] for help
20 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Output #0, rawvideo, to 'pipe:':
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100 Metadata:
Stream #0:0 encoder : Output #0, rawvideo, to 'pipe:':
: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/sLavf58.29.100,
20 fps, Metadata:
20 tbn, 20 tbc encoder :
Lavf58.29.100 Metadata:
encoder : Lavc58.54.100 rawvideo
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, 20 fps, 20 tbn, 20 tbc
Metadata:
Stream #0:0 encoder : : Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/sLavc58.54.100 rawvideo,
20 fps, 20 tbn, 20 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100 Stream #0:0Output #0, rawvideo, to 'pipe:':
: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, Metadata:
20 fps, encoder : 20 tbn, Lavf58.29.10020 tbc
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s
, 20 fps, 20 tbn, 20 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
Stream #0:0
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, , Metadata:
20 fps, 20 fps, encoder : 20 tbn, 20 tbn, Lavc58.54.100 rawvideo20 tbc20 tbc
Metadata:
Metadata:
encoder : encoder : Lavc58.54.100 rawvideoLavc58.54.100 rawvideo
frame=13204 fps=122 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed= 6.1x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
frame=13204 fps=122 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.09x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
frame=13204 fps=122 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.09x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
frame=13204 fps=122 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.09x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
frame=13204 fps=122 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.09x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
frame=13204 fps=122 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.09x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
frame=13204 fps=122 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.09x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
[2024-04-18 12:05:41.062809] Denoising...
[2024-04-18 12:05:41.064407] Denoising...
[2024-04-18 12:05:41.066194] Denoising...
[2024-04-18 12:05:41.066354] Denoising...
[2024-04-18 12:05:41.067592] Denoising...
[2024-04-18 12:05:41.076994] Denoising...
[2024-04-18 12:05:41.082689] Denoising...
[2024-04-18 12:05:41.635887] Background removal...
[2024-04-18 12:05:41.639948] Background removal...
[2024-04-18 12:05:41.641641] Background removal...
[2024-04-18 12:05:41.642357] Background removal...
[2024-04-18 12:05:41.644510] Motion correction...
[2024-04-18 12:05:41.646212] Background removal...
[2024-04-18 12:05:41.648473] Motion correction...
[2024-04-18 12:05:41.649984] Background removal...
[2024-04-18 12:05:41.650904] Motion correction...
[2024-04-18 12:05:41.651986] Motion correction...
[2024-04-18 12:05:41.655712] Motion correction...
[2024-04-18 12:05:41.658694] Motion correction...
[2024-04-18 12:05:41.663167] Background removal...
[2024-04-18 12:05:41.671169] Motion correction...
[2024-04-18 12:05:41.751098] Applying transformation...
[2024-04-18 12:05:41.751383] Applying transformation...
[2024-04-18 12:05:41.751802] Applying transformation...
[2024-04-18 12:05:41.751962] Applying transformation...
[2024-04-18 12:05:41.752343] Applying transformation...
[2024-04-18 12:05:41.752393] Applying transformation...
[2024-04-18 12:05:41.752673] Applying transformation...
[2024-04-18 12:05:41.758730] Saving corrected object...
[2024-04-18 12:05:41.758849] Saving corrected object...
[2024-04-18 12:05:41.759283] Saving corrected object...
[2024-04-18 12:05:41.759840] Saving corrected object...
[2024-04-18 12:05:41.759849] Saving corrected object...
[2024-04-18 12:05:41.760173] Saving corrected object...
[2024-04-18 12:05:41.760474] Saving corrected object...
ffmpeg version 4.2.3ffmpeg version 4.2.3ffmpeg version 4.2.3ffmpeg version 4.2.3ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers Copyright (c) 2000-2020 the FFmpeg developersffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers Copyright (c) 2000-2020 the FFmpeg developers
Copyright (c) 2000-2020 the FFmpeg developers Copyright (c) 2000-2020 the FFmpeg developers
ffmpeg version 4.2.3 built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
Copyright (c) 2000-2020 the FFmpeg developers configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libavutil 56. 31.100 / 56. 31.100
libswresample 3. 5.100 / 3. 5.100
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libpostproc 55. 5.100 / 55. 5.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libavresample 4. 0. 0 / 4. 0. 0
libavutil 56. 31.100 / 56. 31.100
libswscale 5. 5.100 / 5. 5.100
libavutil 56. 31.100 / 56. 31.100
libavutil 56. 31.100 / 56. 31.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libavcodec 58. 54.100 / 58. 54.100
libavcodec 58. 54.100 / 58. 54.100
libavcodec 58. 54.100 / 58. 54.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
libavformat 58. 29.100 / 58. 29.100
libavformat 58. 29.100 / 58. 29.100
libavformat 58. 29.100 / 58. 29.100
libpostproc 55. 5.100 / 55. 5.100
libavdevice 58. 8.100 / 58. 8.100
libavdevice 58. 8.100 / 58. 8.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libavresample 4. 0. 0 / 4. 0. 0
libswresample 3. 5.100 / 3. 5.100
libswscale 5. 5.100 / 5. 5.100
libpostproc 55. 5.100 / 55. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
libavfilter 7. 57.100 / 7. 57.100
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavresample 4. 0. 0 / 4. 0. 0
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libavresample 4. 0. 0 / 4. 0. 0
libswresample 3. 5.100 / 3. 5.100
libswscale 5. 5.100 / 5. 5.100
libpostproc 55. 5.100 / 55. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration: 00:11:00.20, start: 0.000000, bitrate: 104203 kb/s
Stream #0:0: Video: rawvideo, pal8, 806x806, 104207 kb/s, 20 fps, Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
20 tbr, Duration: 20 tbn, Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
20 tbc00:11:00.20Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration: Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration:
Duration: 00:11:00.20, start: , start: Duration: 00:11:00.2000:11:00.20, start: 0.0000000.00000000:11:00.20, bitrate: , start: 0.000000, bitrate: , start: 0.000000, bitrate: 104203 kb/s104203 kb/s
0.000000, bitrate:
, bitrate: 104203 kb/s104203 kb/s104203 kb/s
Stream #0:0 Stream #0:0
: Video: rawvideo, pal8, 806x806, 104207 kb/s: Video: rawvideo, pal8, 806x806, 104207 kb/s Stream #0:0,
20 fps, 20 tbr, 20 tbn, , 20 tbc
20 fps, 20 tbr, Stream #0:020 tbn, : Video: rawvideo, pal8, 806x806, 104207 kb/s20 tbc,
: Video: rawvideo, pal8, 806x806, 104207 kb/s20 fps, 20 tbr, 20 tbn, Stream mapping:
20 tbc,
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))20 fps,
20 tbr, Press [q] to stop, [?] for help
20 tbn, 20 tbc
Stream #0:0: Video: rawvideo, pal8, 806x806, 104207 kb/s, 20 fps, 20 tbr, 20 tbn, 20 tbc
Stream mapping:
Stream #0:0 -> #0:0Stream mapping:
(rawvideo (native) -> rawvideo (native))
Stream #0:0 -> #0:0Press [q] to stop, [?] for help
(rawvideo (native) -> rawvideo (native))Stream mapping:
Press [q] to stop, [?] for help
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration: 00:11:00.20, start: 0.000000, bitrate: 104203 kb/s
Stream #0:0: Video: rawvideo, pal8, 806x806, 104207 kb/s, 20 fps, 20 tbr, 20 tbn, 20 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, 20 fps, 20 tbn, 20 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
Lavf58.29.100
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, 20 fps, 20 tbn, 20 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, 20 fps, 20 tbn, 20 tbc
Metadata:
encoder : Output #0, rawvideo, to 'pipe:':
Lavc58.54.100 rawvideo
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, 20 fps, 20 tbn, 20 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Stream #0:0Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, 20 fps, 20 tbn, 20 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, 20 fps, 20 tbn, 20 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, 20 fps, 20 tbn, 20 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
frame=13204 fps=141 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=7.07x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
frame=13204 fps=138 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.92x
frame=13204 fps=138 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.92x
frame=13204 fps=138 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.92x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%0.000000%video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:
0.000000%
frame=13204 fps=138 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.92x
frame=13204 fps=138 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.92x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
frame=13204 fps=138 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=6.92x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Also, I was wondering whether there's any point in using multiple workers to process a single video? Is it possible each worker is just doing the same in this case?
Hi Jordi,
I have also used if name == __main__:
to fix the same error when trying to run Minian using a .py file in the past, so I am glad you found that fix.
Is the code that you are running the code from your original post? It's unclear to me why each step (denoising, background removal, etc.) is being output multiple times when you have one line that says print.
One minor detail is that I would recommend closing the cluster after all your computations are completed, so start the cluster at the beginning of your script and close it at the end, all within the if name == __main__
statement. In other words your whole Minian pipeline, if you have it as a .py file, should be within the if name == __main__
statement. You don't have to put the settings and imports within this statement, just from the cluster creation and loading video portion onward. You may already be doing this though!
I've never seen the start_method argument in LocalCluster, and it's unclear from the Dask documentation (https://docs.dask.org/en/stable/deploying-python.html) what this argument is doing, so I recommend removing it as none of us in the lab have used it and have no issues.
The point of using multiple workers for Dask is that each worker will handle a chunk of your data - Minian, using Dask arrays built into xarray, will chunk your xarray.DataArray into (by default) 256MB chunks of data (determined through the get_optimal_chk function, and the variable chk will be used when temporally or spatially chunking your data in future computations). Dask then will create a task graph when the save_minian function is used since the actual computations are only occuring when .compute
is called, where it will figure out the optimal way for each worker to process chunks in parallel. More workers means more processes running simultaneously and reduces run time, though only up to a point.
I'm not exactly sure why it's getting stuck from this thread. Reach out to me privately if you want to set up a Zoom call if none of the above recommendations apply to your situation, would love to help you get this working - hopefully we can find an answer that will help the community as well.
Hi Austin,
Yes, everything was being output multiple times because I did not include the rest of the code under the if name == __main__
statement. This fixed that!
Re the start_method
, I think I tried this as a way to fix the issues generated by the previous problem. I think I was starting multiple clusters and that was just messing things further. After putting the code under the if name == __main__
statement, I was able to remove it.
I also found that ffmpeg freezing could be related to not being able to write to its output pipe any longer and that reducing the amount of stream in prints could ameliorate this issue (1,2). This was a long shot and I don't think it's making any difference. But, this explains the extra arguments in write_video
.
I have tried with and without the use of a Dask cluster and the code still gets stuck at the end.
write_video
function (400 fps) and RAM memory spikes up progressively eventually maxing out. Here, I do not include the save_minian
command since there is really no advantage in this case as far as I understand. Unable to find a suitable output format for ''
.I will go ahead and message you privately. Thanks, Austin!
# load dependancies
import os
import sys
import numpy as np
##############################################################################
# Our functions
##############################################################################
from datetime import datetime
def _print(*args, **kw):
print("[%s]" % (datetime.now()),*args, **kw)
##############################################################################
# Configuration
##############################################################################
_print("Configuration...")
# Set up Initial Basic Parameters#
minian_path = "/media/HDD_2TB/jordi/repos/minian/minian"
dpath = "/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/"
minian_ds_path = "/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/minian/"
intpath = "/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/intermediate/"
subset = dict(frame=slice(0, None))
subset_mc = None
interactive = False
output_size = 100
param_save_minian = {
"dpath": minian_ds_path,
"meta_dict": dict(session=-1, animal=-2),
"overwrite": True,
}
# Pre-processing Parameters#
param_load_videos = {
"pattern": r"test_PRIM20231117_GrayScale_AVI.avi",
"dtype": np.uint8,
"downsample": dict(frame=1, height=1, width=1),
"downsample_strategy": "subset",
}
param_denoise = {"method": "median", "ksize": 7}
param_background_removal = {"method": "tophat", "wnd": 15}
# Motion Correction Parameters#
subset_mc = None
param_estimate_motion = {"dim": "frame"}
# Initialization Parameters#
param_seeds_init = {
"wnd_size": 1000,
"method": "rolling",
"stp_size": 500,
"max_wnd": 15,
"diff_thres": 3,
}
param_pnr_refine = {"noise_freq": 0.06, "thres": 1}
param_ks_refine = {"sig": 0.05}
param_seeds_merge = {"thres_dist": 10, "thres_corr": 0.8, "noise_freq": 0.06}
param_initialize = {"thres_corr": 0.8, "wnd": 10, "noise_freq": 0.06}
param_init_merge = {"thres_corr": 0.8}
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"
os.environ["OPENBLAS_NUM_THREADS"] = "1"
os.environ["MINIAN_INTERMEDIATE"] = intpath
##############################################################################
# Import minian
##############################################################################
_print("Importing minian...")
sys.path.append(minian_path)
from minian.cnmf import (
compute_AtC,
compute_trace,
get_noise_fft,
smooth_sig,
unit_merge,
update_spatial,
update_temporal,
update_background,
)
from minian.initialization import (
gmm_refine,
initA,
initC,
intensity_refine,
ks_refine,
pnr_refine,
seeds_init,
seeds_merge,
)
from minian.motion_correction import apply_transform, estimate_motion
from minian.preprocessing import denoise, remove_background
from minian.utilities import (
TaskAnnotation,
get_optimal_chk,
load_videos,
open_minian,
save_minian,
)
from minian.visualization import (
CNMFViewer,
VArrayViewer,
generate_videos,
visualize_gmm_fit,
visualize_motion,
visualize_preprocess,
visualize_seeds,
visualize_spatial_update,
visualize_temporal_update,
write_video,
)
##############################################################################
# module initialization
##############################################################################
_print("Initialiazing...")
dpath = os.path.abspath(dpath)
##############################################################################
# load videos and initialize
##############################################################################
_print("Loading videos...")
# load and get optimal chunks
varr = load_videos(dpath, **param_load_videos)
chk, _ = get_optimal_chk(varr, dtype=float)
# chunks
varr = varr.chunk({"frame": 200, "height": -1, "width": -1}).rename("varr")
# subset video (default:none)
varr_ref = varr.sel(subset)
##############################################################################
# corrections
##############################################################################
# glow removal
_print("Glow removal...")
varr_min = varr_ref.min("frame").compute()
varr_ref = varr_ref - varr_min
# denoise
_print("Denoising...")
varr_ref = denoise(varr_ref, **param_denoise)
# background removal
_print("Background removal...")
varr_ref = remove_background(varr_ref, **param_background_removal)
# motion correction
_print("Motion correction...")
motion = estimate_motion(varr_ref.sel(subset_mc), **param_estimate_motion)
# apply transform
_print("Applying transformation...")
Y = apply_transform(varr_ref, motion, fill=0)
# store corrected video
_print("Saving corrected video...")
_ = write_video(Y.astype(float).rename("Y_fm_chk"), "minian_mc.avi", minian_ds_path, norm=True,
options={"loglevel":"error","hide_banner":"","nostats":""})
# load dependancies
import numpy as np
import os
import sys
from dask.distributed import Client, LocalCluster
##############################################################################
# Our functions
##############################################################################
from datetime import datetime
def _print(*args, **kw):
print("[%s]" % (datetime.now()),*args, **kw)
##############################################################################
# Configuration
##############################################################################
# Set up Initial Basic Parameters#
minian_path = "/media/HDD_2TB/jordi/repos/minian/minian"
dpath = "/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/"
minian_ds_path = "/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/minian/"
intpath = "/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/intermediate/"
subset = dict(frame=slice(0, None))
subset_mc = None
interactive = False
output_size = 100
param_save_minian = {
"dpath": minian_ds_path,
"meta_dict": dict(session=-1, animal=-2),
"overwrite": True,
}
# Pre-processing Parameters#
param_load_videos = {
"pattern": r"test_PRIM20231117_GrayScale_AVI.avi",# r"test_hdrep.avi",
"dtype": np.uint8,
"downsample": dict(frame=1, height=1, width=1),
"downsample_strategy": "subset",
}
param_denoise = {"method": "median", "ksize": 7}
param_background_removal = {"method": "tophat", "wnd": 15}
# Motion Correction Parameters#
subset_mc = None
param_estimate_motion = {"dim": "frame"}
# Initialization Parameters#
param_seeds_init = {
"wnd_size": 1000,
"method": "rolling",
"stp_size": 500,
"max_wnd": 15,
"diff_thres": 3,
}
param_pnr_refine = {"noise_freq": 0.06, "thres": 1}
param_ks_refine = {"sig": 0.05}
param_seeds_merge = {"thres_dist": 10, "thres_corr": 0.8, "noise_freq": 0.06}
param_initialize = {"thres_corr": 0.8, "wnd": 10, "noise_freq": 0.06}
param_init_merge = {"thres_corr": 0.8}
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"
os.environ["OPENBLAS_NUM_THREADS"] = "1"
os.environ["MINIAN_INTERMEDIATE"] = intpath
##############################################################################
# Import minian
##############################################################################
sys.path.append(minian_path)
from minian.cnmf import (
compute_AtC,
compute_trace,
get_noise_fft,
smooth_sig,
unit_merge,
update_spatial,
update_temporal,
update_background,
)
from minian.initialization import (
gmm_refine,
initA,
initC,
intensity_refine,
ks_refine,
pnr_refine,
seeds_init,
seeds_merge,
)
from minian.motion_correction import apply_transform, estimate_motion
from minian.preprocessing import denoise, remove_background
from minian.utilities import (
TaskAnnotation,
get_optimal_chk,
load_videos,
open_minian,
save_minian,
)
from minian.visualization import (
CNMFViewer,
VArrayViewer,
generate_videos,
visualize_gmm_fit,
visualize_motion,
visualize_preprocess,
visualize_seeds,
visualize_spatial_update,
visualize_temporal_update,
write_video,
)
##############################################################################
# module initialization
##############################################################################
if __name__ == '__main__':
_print("Initialiazing...")
dpath = os.path.abspath(dpath)
_print("Starting cluster...")
## Potential cluster configuration
n_workers = int(os.getenv("MINIAN_NWORKERS", 5))
cluster = LocalCluster(
n_workers=n_workers,
memory_limit="10GB",
resources={"MEM": 1},
threads_per_worker=2,
dashboard_address=":8585"
# start_method='fork' # or 'spawn'
)
annt_plugin = TaskAnnotation()
cluster.scheduler.add_plugin(annt_plugin)
try:
client = Client(cluster)
##############################################################################
# load videos and initialize
##############################################################################
_print("Loading videos...")
# load and get optimal chunks
varr = load_videos(dpath, **param_load_videos)
chk, _ = get_optimal_chk(varr, dtype=float)
# chunks
# varr = varr.chunk({"frame": chk["frame"], "height": -1, "width": -1}).rename("varr")
# varr = varr.chunk({"frame": 200, "height": -1, "width": -1}).rename("varr")
varr = save_minian(
varr.chunk({"frame": chk["frame"], "height": -1, "width": -1}).rename("varr"),
intpath,
overwrite=True,
mem_limit='10GB'
)
# varr = open_minian(intpath)
# subset video (default:none)
varr_ref = varr.sel(subset)
##############################################################################
# corrections
##############################################################################
_print("Glow removal...")
# glow removal
varr_min = varr_ref.min("frame").compute()
varr_ref = varr_ref - varr_min
_print("Denoising...")
# denoise
varr_ref = denoise(varr_ref, **param_denoise)
_print("Background removal...")
# background removal
varr_ref = remove_background(varr_ref, **param_background_removal)
_print("Motion correction...")
# motion correction
motion = estimate_motion(varr_ref.sel(subset_mc), **param_estimate_motion)
# _print("Saving estimated motion...")
# save
# motion = save_minian(
# motion.rename("motion").chunk({"frame": chk["frame"]}), **param_save_minian
# )
_print("Applying transformation...")
# apply transform
Y = apply_transform(varr_ref, motion, fill=0)
# _print("Saving corrected object...")
# save transformed object
# Y_fm_chk = save_minian(Y.astype(float).rename("Y_fm_chk"), intpath, overwrite=True)
# Y_hw_chk = save_minian(Y_fm_chk.rename("Y_hw_chk"), intpath,overwrite=True,
# chunks={"frame": -1, "height": chk["height"], "width": chk["width"]},
# )
_print("Saving corrected video...")
# store corrected video
print(Y)
_ = write_video(Y.astype(float).rename("Y_fm_chk"), "minian_mc.avi", minian_ds_path, norm=True,
options={"loglevel":"error","hide_banner":"","nostats":""})
finally:
##############################################################################
# close cluster
##############################################################################
_print("Closing cluster client...")
# Close the client and cluster explicitly
client.close()
cluster.close()
[2024-04-21 13:03:11.411790] Initialiazing...
[2024-04-21 13:03:11.411819] Starting cluster...
[2024-04-21 13:03:15.313842] Loading videos...
loading 1 videos in folder /media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7.5.0 (crosstool-NG 1.24.0.123_1667d2b)
configuration: --prefix=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac --cc=/home/conda/feedstock_root/build_artifacts/ffmpeg_1590573566052/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, avi, from '/media/HDD_4TB_1/jordi/calcium_imaging/hdrep_primary_cultures/uncorrected/test_PRIM20231117_GrayScale_AVI.avi':
Duration: 00:11:00.20, start: 0.000000, bitrate: 104203 kb/s
Stream #0:0: Video: rawvideo, pal8, 806x806, 104207 kb/s, 20 fps, 20 tbr, 20 tbn, 20 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, rawvideo, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 806x806, q=2-31, 103941 kb/s, 20 fps, 20 tbn, 20 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
frame=13204 fps=387 q=-0.0 Lsize= 8376752kB time=00:11:00.20 bitrate=103941.8kbits/s speed=19.3x
video:8376752kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
[2024-04-21 13:04:06.507305] Glow removal...
[2024-04-21 13:04:09.475022] Denoising...
[2024-04-21 13:04:09.479128] Background removal...
[2024-04-21 13:04:09.481288] Motion correction...
[2024-04-21 13:04:11.306973] Applying transformation...
[2024-04-21 13:04:11.312548] Saving corrected video...
[NULL @ 0x55db65d909c0] Unable to find a suitable output format for ''
: Invalid argument
[2024-04-21 13:43:42.374401] Closing cluster client...
Traceback (most recent call last):
File "hdrep_minian_pipeline_dask.py", line 254, in <module>
_ = write_video(Y, "minian_mc.avi", minian_ds_path, norm=True, options={"loglevel":"error","hide_banner":"","nostats":""})
File "/media/HDD_4TB_1/jordi/miniconda3/envs/minian/lib/python3.8/site-packages/minian/visualization.py", line 1276, in write_video
process.stdin.write(np.array(blk).tobytes())
BrokenPipeError: [Errno 32] Broken pipe
Issue was fixed - the issue was due to commenting out the intermediate save steps, which you can see in the code shown above!
Hi,
We are using minian to correct motion in some calcium imaging data. We first generate HIS files which we then convert to AVI to use as input with minian. The input videos weigh about 8 GB and we're finding that ffmpeg requires an absurd amount of memory when executing either
Y_fm_chk = save_minian(Y.astype(float).rename("Y_fm_chk"), intpath, overwrite=True)
or
write_video(Y_fm_chk, "minian_mc.avi", minian_ds_path)
We have tested the code with a smaller AVI file, and it seemed to work well, although it also required a ridiculous amount of RAM. However, with the real videos, the process ends up getting killed (the machine we're using has 64 GB of RAM). We have also tried using dusk to limit the memory, but that doesn't seem to work either.
I'm attaching the code and the dependencies for your reference. Any help would be greatly appreciated.
Thanks, jordi