2021年3月19日金曜日

Cellprofiler debug版 インストール

 https://github.com/CellProfiler/CellProfiler/wiki/Source-installation-%28OS-X-and-macOS%29

の通りやっていますが、うまくいっていないのでメモ。

macです。


Homebrewのインストール

Warning: The Ruby Homebrew installer is now deprecated and has been rewritten in

Bash. Please migrate to the following command:

  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

というエラーがでるがいちおううごく。

さらに、

Error:

  homebrew-core is a shallow clone.

To `brew update`, first run:

  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

This command may take a few minutes to run due to the large size of the repository.

This restriction has been made on GitHub's request because updating shallow

clones is an extremely expensive operation due to the tree layout and traffic of

Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you

automatically to avoid repeatedly performing an expensive unshallow operation in

CI systems (which should instead be fixed to not use shallow clones). Sorry for

the inconvenience!

Failed during: /usr/local/bin/brew update --force --quiet

というエラーもるので、

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

をやる。これは成功。


java インストール

brew cask install java
するも、Homebrewのcaskがないらしい。
Error: Unknown command: cask
というエラー。

調べると、
brew install java --cask           
でできるとか。

Updating Homebrew...
Error: Cask 'java' is unavailable: No Cask with this name exists.
とやるとやっぱり無理。

caskがないのがやっぱりおかしいのでは?
とおもって。https://devqa.io/brew-install-java/ でみたようにやってみる。
brew tap homebrew/cask-versions
をやると、成功。
(一回exited 128 でエラーになってたけど多分これはネットワークコネクションの問題。)
brew tap caskroom/cask
では、
Error: caskroom/cask was moved. Tap homebrew/cask instead.
なので、そのとおりにやる。なにもでない。

https://github.com/Homebrew/homebrew-cask/issues/90904#issuecomment-709661779
これがうまくいった。


echo 'export PATH="/usr/local/opt/openjdk/bin:$PATH"' >> ~/.zshrc
って出てきたのでやっておく。

Python 

これははいってるので確認だけ。
python --version
Python 3.7.4

MySQL

これは成功。

以上、できたので、
git cloneでインストールしました。

その後

pip3 install -e .
でエラー。
 status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement python-javabridge==4.0.3 (from cellprofiler)
ERROR: No matching distribution found for python-javabridge==4.0.3
というエラーメッセージ。

2021年3月11日木曜日

MATLABでfor each

 pythonだとA=[1,3,2,4]みたいな配列でループ回したいときは、

for num in A:

    print(num)

ってやったら"1 3 2 4"ってプリントされるみたいな書き方ができるとおもう。

でも、MATLABではないので、

for num=1:length(A)

    disp(A(num))

end

みたいにやるしかないですかねぇ。

MATLAB 構造体から配列への変換

 構造体の1つのfieldがすべて同じデータ型のとき、array(matrix)に変換するやり方。


nums(1).f = 1;
nums(2).f = 2;
nums(3).f = 3;

allNums = [nums.f]

とやればよいらしい。
https://jp.mathworks.com/help/matlab/matlab_prog/access-multiple-elements-of-a-nonscalar-struct-array.html

そうじゃない場合のやり方とか、functionのかけ方とかも上のリンクにあり。

MATLAB cell配列ならなんでもぶちこめる

 structの配列もつくれる。あと文字列の配列もcell配列。

とにかくループ回したいものは配列に入れたほうが圧倒的に楽なので、

cell配列にすると良い。

呼び出すとき{i} となるのが特徴。

MATLAB 構造体の条件付きの取り出しかた

 MATLABで構造体(struct)の中で条件づけて取り出したいとき。

structでwhereをやりたいときは、indexを経由する。


struct が Sとして、以下サイトから引っ張ってきたもの。

>> S(1).a = 1;
>> S(2).a = 2;
>> S(3).a = 3;
>> idx = [S.a]>2
idx =
0 0 1
>> S(idx).a
ans = 3

という感じで取り出せる。

S_sub = S(idx)

とすると、その条件に当てはまるところだけ取り出せる。


[参考]

https://jp.mathworks.com/matlabcentral/answers/422504-find-indices-in-structure-array-for-structures-with-field-meeting-a-condition