Giter Site home page Giter Site logo

adamspierer / freeclimber Goto Github PK

View Code? Open in Web Editor NEW
14.0 4.0 5.0 106.48 MB

FreeClimber is a background-subtracting particle detection platform designed to quantify group climbing performance in a Drosophila negative geotaxis (climbing) assay

License: MIT License

Python 99.86% PLSQL 0.14%
local-linear-regression flies particle-detection drosophila drosophila-behaviour climbing locomotion scientific-software scientific-research animal-behavior

freeclimber's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

freeclimber's Issues

Issues with FreeClimber_gui.py

Hello Adam,
I have installed FreeClimber in a dedicated conda environment with python3.6, as recommended, and made sure I have all the required packages in the correct version, as required in your tutorial. However, when I attempt to run the GUI pythonw ./scripts/FreeClimber_gui.py with or without --video_file I receive the following error message:

  File "./scripts/FreeClimber_gui.py", line 434
    print('## FreeClimber ##', file=f)
                                   ^
SyntaxError: invalid syntax

I am not a Python expert, but I can't see any obvious error in the code around line 434. Do you have any idea of what the problem could be?

# packages in environment at /Users/vincent/opt/anaconda3/envs/python36:
#
# Name                    Version                   Build  Channel
argparse                  1.1                      pypi_0    pypi
ca-certificates           2022.07.19           hecd8cb5_0    defaults
certifi                   2021.5.30        py36hecd8cb5_0    defaults
cycler                    0.11.0                   pypi_0    pypi
ffmpeg-python             0.2.0                    pypi_0    pypi
freeclimber               0.3.1.1                  pypi_0    pypi
future                    0.18.2                   pypi_0    pypi
kiwisolver                1.3.1                    pypi_0    pypi
libcxx                    14.0.6               h9765a3e_0    defaults
libffi                    3.3                  hb1e8313_2    defaults
matplotlib                3.1.3                    pypi_0    pypi
ncurses                   6.3                  hca72f7f_3    defaults
numpy                     1.18.1                   pypi_0    pypi
openssl                   1.1.1q               hca72f7f_0    defaults
pandas                    1.0.0                    pypi_0    pypi
pillow                    8.4.0                    pypi_0    pypi
pip                       20.0.2                   pypi_0    pypi
pyparsing                 3.0.9                    pypi_0    pypi
pyproject-indirect-import-detector 0.1.2                    pypi_0    pypi
python                    3.6.13               h88f2d9e_0    defaults
python-dateutil           2.8.2                    pypi_0    pypi
pythonw                   3.0.3                    pypi_0    pypi
pytz                      2022.4                   pypi_0    pypi
pyyaml                    6.0                      pypi_0    pypi
readline                  8.1.2                hca72f7f_1    defaults
result                    0.6.0                    pypi_0    pypi
scipy                     1.4.1                    pypi_0    pypi
setuptools                56.2.0                   pypi_0    pypi
six                       1.16.0                   pypi_0    pypi
sqlite                    3.39.3               h707629a_0    defaults
stdlib-list               0.8.0                    pypi_0    pypi
termcolor                 1.1.0                    pypi_0    pypi
tk                        8.6.12               h5d9f67b_0    defaults
toml                      0.10.2                   pypi_0    pypi
trackpy                   0.4.2                    pypi_0    pypi
wheel                     0.37.1             pyhd3eb1b0_0    defaults
wxpython                  4.0.4                    pypi_0    pypi
xz                        5.2.6                hca72f7f_0    defaults
zlib                      1.2.12               h4dc903c_3    defaults

Error using the command line

I get an error when I try to use the batch utility with a config file I generated using the GUI. My .MOV files are in a sub-folder called videosA. The program throws an error on the first file. There is a new folder created in the main directory called "videosAlog" instead of "log" subfolder created in the main "videosA" folder. When I physically create this subfolder and move the logs, I am able to execute the code normally, so I suppose it must be a typo (missing "/" perhaps?) in the script that initiates the analysis.

Console log below:


########################################################################
## FreeClimber v.0.4.0 #################################################
## Please cite: https://doi.org/10.1242/jeb.229377######################
## Beginning program @ 2023-09-14 11:01:58 #############################
########################################################################
Creating completed .log file:  ./videosAlog/completed.log
Creating skipped .log file:  ./videosAlog/skipped.log
========================================================================
== [1 || 46] 10_1.MOV ==================================================
========================================================================

-- [ Step 1  ] Cleaning and format image stack
-- [ Step 2  ] Identifying spots
-- [ Step 3  ] Visualize spot metrics :: False
-- [ Step 4a ]   - Setting spot threshold
-- [ Step 4b ]   - Filtering by signal threshold
-- [ Step 4c ]   - Filtering by eccentricity/circularity
-- [ Step 4d ]   - Trimming outliers (if indicated)
-- [ Step 4e ]   - Assigning spots to vials
-- [ Step 4f ]   - Saving raw data file
Appending to log/skipped.log:  ./videosA\10_1.MOV
Traceback (most recent call last):
  File "./scripts/FreeClimber_main.py", line 475, in main
    fc.process(video_file = File,variables = None, config_file = fc.config_file)
  File "./scripts/FreeClimber_main.py", line 196, in process
    d.step_4()# Filters and processes data detected points
  File "D:\freeclimber\FreeClimber\scripts\detector.py", line 1050, in step_4
    self.df_big.to_csv(self.path_data, index=None)
  File "D:\Anaconda\envs\python36\lib\site-packages\pandas\core\generic.py", line 3204, in to_csv
    formatter.save()
  File "D:\Anaconda\envs\python36\lib\site-packages\pandas\io\formats\csvs.py", line 188, in save
    compression=dict(self.compression_args, method=self.compression),
  File "D:\Anaconda\envs\python36\lib\site-packages\pandas\io\common.py", line 428, in get_handle
    f = open(path_or_buf, mode, encoding=encoding, newline="")
OSError: [Errno 22] Invalid argument: './videosA\x08_1.raw.csv'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./scripts/FreeClimber_main.py", line 489, in <module>
    main()
  File "./scripts/FreeClimber_main.py", line 479, in main
    fc.log_video(completed=False, file_name = File)
  File "./scripts/FreeClimber_main.py", line 281, in log_video
    with open(self.path_project + '/' + path,'a') as f:
FileNotFoundError: [Errno 2] No such file or directory: './videosA/log/skipped.log'

conflict between self.crop_n in step_1() and self.image_stack in local_linear_regression() for detector.py

Hi, adamspierer,
thank you so much for such an amazing tool!
The automation of fly spotting function really rocks!

While I was processing some climbing videos, I noticed some unusual behaviors when running FreeClimber with example movie: w1118_m_2_1.mov

This movie has 145 frames in total, instead of processing all of them, if I set the number of frames to be processed by FreeClimber between 0 and 90.
i.e.,

crop_0=0
crop_n=90
...
window=50

shown in **.cfg file.

FreeClimber_main.py would stop and give some error message at step_6(), the local_linear_regression() place.
the error message is like 'Error: input frame is not accounted for in current DataFrame'.

I checked the source code, and I guess it has something to do following lines of code in detector.py:

#line 75
self.image_stack = self.video_to_array(video_file,loglevel='panic')
#line 806
for i in range(len(self.image_stack) - self.window):   
#line 862-866
            self.clean_stack = self.crop_and_grayscale(stack,
                         y=y, y_max=y_max,
                         x=x, x_max=x_max,
                         first_frame=self.crop_0, last_frame=self.crop_n)

self.image_stack is set to be all frames contained in a mov file at the init;
detector.py step_1() crops frames and sends this subset of frames to downstream processing;
after fly detection, when it comes to local regression to estimate velocity, the sliding window still 'slide' through all frames in the mov instead of those cropped ones.

It works pretty well with all frames, but would run into some problem if crop_n < total.frame - window.size.

Bests!
Ming

Question about parameters

Hi! I was wondering if there was a way I could have the program analyze by 120 second long video, in a short period of time? Or if it is possible to do so?

GUI pythonw not found

Hi there,

I would really appreciate help in running the video files from the GUI (on Mac). I managed to run it from the command line to get an output in csv form but when executing the command below:

pythonw ./scripts/FreeClimber_gui.py --video_file ./example/w1118_m_2_1.h264

I get this output:

zsh: command not found: pythonw

pythonw do nothing (ffmpeg problem?)

Hello,

I tried to follow the steps described in https://github.com/adamspierer/FreeClimber/blob/master/TUTORIAL.md

I am pretty sure I followed all the instructions, but when I try to run:

(python36) C:\Users\myUser\Desktop\free\FreeClimber>pythonw .\scripts\FreeClimber_gui.py --video_file .\example\w1118_m_2_1.avi

Is does absolutely nothing. I tried to redirect the output in a file, and I have this. I installed ffmpeg, added to the environment variables, but I am stuck. Do you have an idea?

Thanks a lot for your help and best regards!

Traceback (most recent call last):
File "C:\Users\myUser\Desktop\free\FreeClimber\scripts\detector.py", line 276, in video_to_array
out,err = (ffmpeg
AttributeError: module 'ffmpeg' has no attribute 'input'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File ".\scripts\FreeClimber_gui.py", line 40, in OnInit
frame = create(None, file_name)
File ".\scripts\FreeClimber_gui.py", line 782, in create
return main_gui(parent, file_path)
File ".\scripts\FreeClimber_gui.py", line 125, in init
self.load_video()
File ".\scripts\FreeClimber_gui.py", line 192, in load_video
variables = vars)
File "C:\Users\myUser\Desktop\free\FreeClimber\scripts\detector.py", line 76, in init
self.image_stack = self.video_to_array(video_file,loglevel='panic')
File "C:\Users\myUser\Desktop\free\FreeClimber\scripts\detector.py", line 283, in video_to_array
print('!! Could not read in video file to an array. Error message (if any):', err)
UnboundLocalError: local variable 'err' referenced before assignment

########################################################################

FreeClimber v.0.4.0

Please cite: https://doi.org/10.1242/jeb.229377

Beginning program @ 2023-09-08 14:57:10

########################################################################
--> Video file: .\example\w1118_m_2_1.avi
Loading: .\example\w1118_m_2_1.avi

!! Could not read .\example\w1118_m_2_1.avi into FreeClimber. Likely due to unacceptable video file or FFmpeg not installed
!! Could not read in video file metadata
OnInit returned false, exiting...

GUI

Hello,

I am a biologist with little python experience. I have managed to install the FreeClimber files, but I'm not sure how to activate the GUI. have made an environment using conda and attempted to follow the tutorial. However, I am confused by this from the tutorial:

"A required .cfg is needed to run the command line tool. This file is generated by the GUI, or can be modified from the provided example.cfg file. The program will find all specified video files of a common type (file_suffix) that are nested within the specified parent folder (project_path), rather than where the configuration file is held." What does this mean and what do I do? I just want to start the GUI so I can input my video and parameters. Thank you so much for your help,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.