ImageJ串联宏单独运行,但会出现错误:在较大的宏中,“文件名”不是“ image1”的有效选择

时间:2019-06-16 13:18:27

标签: concatenation imagej

我正在分析非共振的MRI图像的超堆栈,需要将其编译为一个共振图像的堆栈。我需要手动执行此操作的一部分,因此我告诉程序我需要多少个子堆栈,然后指定切片号。然后,根据样本的方向(我也输入:大到小锥度(B-S)或小到大锥度(S-B)),图像需要针对该方向进行拼接。理想情况下,我想弄清楚如何制作一个循环,以便该串联对我可能拥有的任何数量的子堆栈都有效,但是在此阶段我什至不知道该如何进行。

在特定的子堆栈名称之前,我尝试在名称[],(),“”,&之前加上“ +”,试图使用selectWindow ...其他我忘记的东西。 ..

import requests
from bs4 import BeautifulSoup as bs
import pandas as pd


def add_reviews(s, soup, results):
    for review in soup.select('.review-article'):
        info = review.select_one('a')
        identifier = review.select_one('[reviewid]')['reviewid']
        data['reviewid'] = identifier
        title = info.text
        link = info['href']
        rating = len(review.select('.rated-star'))
        r = s.post('https://www.mouthshut.com/review/CorporateResponse.ashx', data)
        soup2 = bs(r.content, 'lxml')
        review = ' '.join([i.text for i in soup2.select('p')])
        row = [title, link, rating, review]
        results.append(row)

url = 'https://www.mouthshut.com/product-reviews/ICICI-Lombard-Auto-Insurance-reviews-925641018-page-{}'
data = {'type': 'review', 'reviewid': '', 'catid': '925641018', 'corp': 'false', 'catname': ''}
results = []

with requests.Session() as s:
    r = s.get('https://www.mouthshut.com/product-reviews/ICICI-Lombard-Auto-Insurance-reviews-925641018')
    soup = bs(r.content, 'lxml')
    pages = int(soup.select('#spnPaging .btn-link')[-1].text)
    add_reviews(s, soup, results)
    if pages > 1:
        for page in range(2, pages + 1):
            r = s.get(url.format(page))
            soup = bs(r.content, 'lxml')
            add_reviews(s, soup, results)

df = pd.DataFrame(results, columns = ['Title', 'Link', 'Rating', 'Review'])
print(df)      

这是当我手动连接它们时,记录功能提供给我的代码...

    //SPECIFIES NUMBER OF STACKS TO MAKE AND LOOPS
    numberofstacks=getNumber("How many stacks?", 3);
       i=0;
       do {
    selectWindow("2D"); 
    first=getNumber("Enter first slice:", 0);
    last=getNumber("Enter last slice:", 0);
    run("Make Substack...", "  slices="+first+"-"+last);
    getInfo("image.filename");
    rename("substack"+i);
    i=i+1;
    }while (i<numberofstacks);
   //INSERTS PAUSE FOR USER TO ADJUST CONTRAST IN STACKS
   waitForUser("Press OK to continue");
   //MAKES INPUT TO DECIDE IF CODING S-B or B-S
   bs=getString("Scrolling from left to right does the tooth start big 
      (b) or small (s)?", "b");
   if (bs=="b") {
      run("Concatenate...", "  title=[Concatenated Stacks] keep 
      image1=substack3 image2=substack2 image3=substack1 image4=substack0 
      image5=[-- None --]");
   run("In [+]");
   run("In [+]");
   } 
   run("Concatenate...", "  title=[Concatenated Stacks] keep 
      image1=substack0 image2=substack1 image3=substack2 image4=substack3 
      image5=[-- None --]");
   run("In [+]");
   run("In [+]");

每当我将确切的代码输入到较大的宏中时,它就会告诉我,““ subimage3”不是“ image1”的有效选择。”

0 个答案:

没有答案